Re:Rust and Nix = easier Unix systems programming
by luckydude on Thursday April 14, 2016 @11:26AM
(#11497447)
I tend to agree with you with one caveat. We did a C like scripting language and added one thing that C was missing, a variable value that is "undefined" which is not the same as zero. Really simple but now you can do stuff like
pid_t p;
if (defined(p = fork()) {
// parent / child stuff here
} else {
// fork error here
}
It's pretty much the same as try / catch, we just implemented it as part of the variable. And any scalar or complex type can be undefined.
I suspect if C had this a lot of these code samples would be a little more clear. Maybe? Dunno, it's worked well for us. And we like C a lot.
pid_t p;
if (defined(p = fork()) { // parent / child stuff here } else { // fork error here }
It's pretty much the same as try / catch, we just implemented it as part of the variable. And any scalar or complex type can be undefined.
I suspect if C had this a lot of these code samples would be a little more clear. Maybe? Dunno, it's worked well for us. And we like C a lot.