News for hackers. Stuff that matters.
Re:An Open Letter to JavaScript Leaders Regarding Semicolons by olavk on Monday December 20, 2010 @11:40AM (#2024809)
The point is that always adding semicolons does not solve the weirdness problem. Consider:

    return
         17
This returns undefined, which is counter-intuitive if you come from other c-style syntax languages. But if you say "always terminate statements with a semicolons, otherwise weirdness happens", the intuitive fix is:

    return
        17;
Which still doesn't solve the problem. You have to remember an additional rule: "Don't insert line breaks in the middle of a statement, if the line break could be interpreted as a statement terminator." Or to put it another way: If you are in doubt, don't use a line break.

The problem isn't really if statements should be terminated with a semicolon or not. The problem is to decide when it is safe to insert a line break when it is not intended to terminate the statement.

Re:An Open Letter to JavaScript Leaders Regarding Semicolons by gcr on Monday December 20, 2010 @11:48AM (#2024842)
Whoever linebreaks return statements like that deserves what's coming to them.

But I get what you're saying. Simple, consistent rules are better for teamwork.

Re:An Open Letter to JavaScript Leaders Regarding Semicolons by pdw on Monday December 20, 2010 @02:05PM (#2025349)
I do that sometimes (obviously not in JavaScript), to split up long lines in situations such as this:

  bool is_foo_possible() {
    return
      test_first_condition() &&
      test_second_contition() &&
      test_third_condition()
  }
I don't think that's very horrible.
Re:An Open Letter to JavaScript Leaders Regarding Semicolons by BrandonM on Monday December 20, 2010 @03:26PM (#2025651)
I would tend to write that:

  bool is_foo_possible() {
    return test_first_condition()
      && test_second_contition()
      && test_third_condition()
  }
I prefer to put my infix operators at the beginning of continuation lines, because that makes it immediately clear from a glance that it's a continuation line.
Re:An Open Letter to JavaScript Leaders Regarding Semicolons by IsaacSchlueter on Monday December 20, 2010 @07:33PM (#2026401)
I do this as well.

For a while, I tried to stick to the rule that "return\n" was not allowed. When I meant to return undefined, I'd write "return undefined".

In the end, I abandoned that rule, because too many of my functions return undefined. But it's kind of a nice thing. When I do get around to building that linter, I might make `return\s*\n` verboten.

Re:An Open Letter to JavaScript Leaders Regarding Semicolons by olavk on Sunday January 02, 2011 @06:42AM (#2059893)
You could just write "return;", that would make it obvious that no value is returned.
Re:An Open Letter to JavaScript Leaders Regarding Semicolons by gcr on Tuesday December 21, 2010 @03:15PM (#2029172)
OH. Good point.