Hacker News new | ask | show | jobs
by latchkey 5287 days ago
Kind of a side note to the posting, but I just have to say: Please make your usage of parens consistent. If you aren't going to use them, don't use them everywhere.

Here is an example of what I'm talking about:

if isAir cx, cy, cz + 1 then addPlane('near', block)

Should be:

if isAir cx, cy, cz + 1 then addPlane 'near', block

Personally, I use them everywhere because I like having the stronger visual clue that this is a method I'm calling. I think making them optional in CS was a bad idea.

if isAir(cx, cy, cz + 1) then addPlane('near', block)

imho, so much more readable.

1 comments

Not allowing parens would mess up the usage of anonymous functions.
Not sure I understand you or maybe you don't understand me. I was talking about using parens for method/functional calls, not getting rid of them from CS.
I understand. If you don't have parens on method calls, how could you use an anonymous function that is not the last parameter? For example:

  doSomething(->
    # stuff happens
  ), onerror
First, your code snippet is wrong: you need a space before your first paren.

In coffeescript you can do any of the following, or a few other variants:

  doSomething ->
      stuff
    , onerror

  doSomething(->
      stuff
    , onerror
  )

  doSomething (->
      stuff
    ), onerror

  doSomething(
    ->
      stuff
    onerror
  )

  doSomething (-> stuff), onerror
I had this question a while back as well. Take a look at the discussion here, including Jeremy's thoughts: https://gist.github.com/1215863
I totally agree with you.