I like the way
if (!foo) bar;
gets turned into bar unless foo
:) if (!foo) bar;
gets turned into bar unless foo
:) return x unless err
return y if condition
...
return z
Keeping all of your "return"s at the start of the line makes it much easier to see, at a glance, what the possible return values of your function are. (And, of course, when you see a "return" in the middle of your function, you know there must be a condition attached.) if (!err) {
return x;
}
if (condition) {
return y;
}
... if (!err) return x;
if (condition) return y;How do you feel then about things like this?
variable = if something
val
else
another_val
end
(insert your personal indentation choice, of course)sorry, ya lost me there. Are you referring to a language interpreter? In that case, which one?
The only difference I can see for interpreters is that it necessitates parsing the entire line before acting, which all but the most highly-tuned (and designed for this purpose) interpreted-languages probably already do.
Don't get me wrong, I like coffee script and I find the tool linked on this thread quite useful, but come on... rewriting all the 'ifs' as 'unless' jut because you can looks pointless and silly to me. Just my opinion.