News for hackers. Stuff that matters.
Re:Of parser-fetishists and semi-colons by h2s on Monday April 16, 2012 @12:47PM (#3848140)
Haven't yet seen anyone point out what unpleasantly quirky code this was in the first place:

    !isActive && $parent.toggleClass('open')
It should have been written like this:

    if (!isActive) {
         $parent.toggleClass('open');
    }
What if somebody needs to add a second bit of code to be executed if isActive is false? In the first case, they'd have to refactor the code into an if statement before adding it. It should have been an if statement in the first place.

If you want something to happen if something is true, then you should use an if statement. This is not controversial stuff. Don't look for "clever" ways to misappropriate other parts of the syntax in order to appeal to your own personal minimalist aesthetic taste. Be cooperative.

Edit: On re-reading this it comes off as preachy. In fact I've very recently taken a closer look at some of my own "little quirks" and realised how unhelpful they were for other developers. I guess I'm embarrassed about that and want to spread the embarrassment around.

Re:Of parser-fetishists and semi-colons by miahi on Monday April 16, 2012 @01:37PM (#3848409)
You can always continue with

  !isActive && ($parent.toggleClass('open') || do_something_else())
but this is write-only code.

This actually reminds me of some cool hacks with structure pointers and functions in the Linux kernel.

Re:Of parser-fetishists and semi-colons by luser001 on Monday April 16, 2012 @03:06PM (#3848802)
Unless I'm mistaken 'do_something_else()' won't get executed if toggleClass() returns a value that evaluates to true. Because of short-circuit boolean evaluation.
Re:Of parser-fetishists and semi-colons by philipjrose on Monday April 16, 2012 @03:21PM (#3848886)
That's correct. You could use:

  !isActive && ($parent.toggleClass('open'), do_something_else())
but I don't think anyone would advise it.
Re:Of parser-fetishists and semi-colons by chris_wot on Monday April 16, 2012 @07:34PM (#3850078)
Actually, you are all missing Crockford's real point, which is that they are considering making ! a binding deference of function objects. If they do, then this:

  clearMenus()
  !isActive && $parent.toggleClass('open')
Becomes this:

  clearMenus()!isActive && $parent.toggleClass('open');
And not this:

  clearMenus();
  !isActive && $parent.toggleClass('open');
The no semi-colon crowd is ridiculous. There are no good arguments for omitting semicolons!
Re:Of parser-fetishists and semi-colons by chris_wot on Tuesday April 17, 2012 @02:47AM (#3851518)
Why has this been downvoted? If you don't agree, try commenting - don't downvote! Sheesh?
Re:Of parser-fetishists and semi-colons by blasdel on Tuesday April 17, 2012 @02:29AM (#3851471)
there are even fewer good arguments for changing the semantics of the fucking logical negation operator 17 years down the line in a dynamic language with billions of end users and no discrete versioning
Re:Of parser-fetishists and semi-colons by chris_wot on Tuesday April 17, 2012 @02:49AM (#3851521)
About as logical as using the logical negation operator for a purpose other than logical negation. :-)

So, how would you implement this dereferencing feature? given that this wouldn't be an issue if you added a semicolon, not sure why you are so hetup there...

Re:Of parser-fetishists and semi-colons by arrakeen on Monday April 16, 2012 @02:35PM (#3848648)
there's also the case of being able to set a breakpoint for the code that executes only when !isActive == true