Hacker News new | ask | show | jobs
by userbinator 4038 days ago
I'm not the parent, but as someone who also doesn't prefer aligning variable initialisers I can say the reason is that declaring variables and initialising them is not something I see as being tabular --- they're just a sequence of statements, and I wouldn't align them just like I wouldn't do this with a series of function calls:

    foo        (5, 7);
    barbar        (j);
    do_stuff(6, 1, 7);
or this with flow control statements:

    if   (x == y) {
      ...
    }
    for  (...) {
      ...
    }
    while(...) {
      ...
    }
Things like array initialisers, however, I do align.

    int n[16] = {
      15, 17, 22, 38,203,155,  7, 10,
     255, 11, 44,  1,  0,  0,  5,227
    };
To someone who reads code the way a computer parses it (as I do), the added space can completely throw them for a loop.

Actually, if you were really reading "the way a computer parses it", you'd ignore whitespace completely.

1 comments

> Actually, if you were really reading "the way a computer parses it", you'd ignore whitespace completely.

I write a lot of coffeescript ;-)

Joking aside, on my current project we elide the parentheses when making function calls with arguments. So:

    myfunc(foo)

    myfunc (foo) ->
is an important difference when I'm reading the code. If you write:

    myfunc       (foo) ->
it means the same thing, but it completely throws me for a loop because I have to look ahead too far. So you are right, I don't look at it the way the interpreter does. I'm inferior and can only handle a grammar with a single look ahead ;-)