Closed jackie-t closed 5 years ago
Haxe doesn't have empty statements (or "statements" at all, really). The ;
is used to separate expressions inside a block.
@jackie-t why not just
if (!toast_already_done) {
var b = get_some_bread();
pop_in_the_toaster(b);
}
?
@jackie-t, you could consider adding a comment explicitly stating that it should be a no-op:
if (toast_already_done) {
// nothing left to do
}
else {
var b = get_some_bread();
pop_in_the_toaster(b);
}
Hi all,
@ktimothy
why not just
if (!toast_already_done) {
In some situations it makes sense to avoid negations in order to make the code more readable. http://www.chrisrolle.com/en/blog/positive-coding-style Seems more like a workaround than a fix.
@jonasmalacofilho That's what I've been doing, but it adds clutter when the code itself is very clear already. Would be more of a workaround than a fix.
The remaining comments don't seem to answer my question. I've read the "everything is a expression" page multiple times, so linking me that as a close reason doesn't help at all. For me, adding an ";" doesn't seem very different to a block with no expression in it (in neither case, the block contains an expression - so the notion of having no expression needs to exist in haxe somehow. The ";" separates expressions, as @nadako stated, just that there is no expression on either side).
Anyhow, as you guys can tell from the delay in my response, I currently moved on to projects in other programming languages. I was just mildly curious what happened to the report, since I wrote stuff in C# and TS today, thought about how nice it is that neither of them force a specific style on me, and was reminded of haxe. Don't get me wrong, haxe is nice, but those things just feel a bit clunky. I still use haxe for toy projects, but it's not really a priority.
Thanks!
This should go through https://github.com/HaxeFoundation/haxe-evolution, though I suppose it's just pointless to expect some random JavaScript code to just work without any modification in Haxe, or trying to allow decaf coffee in Haxe if actually there is no concept of coffee at all.
I have a lot of code like this:
This, in haxe, isn't just a warning, but an outright error. The "fix" of course is easy enough - you remove the ";" - but it seems to be strange to treat it as an error.
Is there any compelling reason (other than trying to force a specific code style) why empty statements are not allowed? What would make them so majorly different to
which does actually look incomplete (forgot to write anything in the bracket / code folding active) to me?