News for hackers. Stuff that matters.
Re:Which one will execute faster, if(flag==0) or if(0==flag)? by Jach on Friday January 07, 2011 @11:49PM (#2082264)
Personally I'm more against "=" being the assignment operator, which should be ":=". But I have no problems with the actual syntax so long as it's clearly defined what (x = y) returns. (Does it return y? x? true if assignment was successful? Does it call a operator=() function that blows up the moon?) In languages where the line between statement and expression is nil it would be especially odd to flag this as illegal.

Flash Builder's Actionscript compiler has saved me from that a couple times in memory, though, so I agree it should be a warning if you don't wrap it in extra parens. gcc also will complain.

Re:Which one will execute faster, if(flag==0) or if(0==flag)? by chromatic on Saturday January 08, 2011 @12:07AM (#2082311)
Personally I'm more against "=" being the assignment operator, which should be ":=".

The problem with := is that you run the risk of the Pascal trap, in that no language which uses := for assignment has ever become more popular than Pascal.

Re:Which one will execute faster, if(flag==0) or if(0==flag)? by redthrowaway on Saturday January 08, 2011 @12:29AM (#2082356)
In general, I just don't like hitting shift, and so am opposed to :=.
Re:Which one will execute faster, if(flag==0) or if(0==flag)? by Jach on Saturday January 08, 2011 @02:11AM (#2082531)
Let's compromise and make it ;=.
Re:Which one will execute faster, if(flag==0) or if(0==flag)? by redthrowaway on Saturday January 08, 2011 @06:31AM (#2082871)
I'd rather if the compiler simply determined whether or not it was used as an assignment or comparison and just go with a single =.