Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'm not familiar with Coffeescript. Maybe I should have a look. My thought was that getting the right level of indentation for something like:

    my_func_with_callbacks(arg1, def(x):
        foo()
        bar(),
        5)
would be a pain in terms of defining sensible rules and ensuring they are parsed correctly. So right now, I'm going for something closer to Ruby syntax. But it may just be a symptom of a lack of imagination. I'll remember to investigate Coffeescript when I revisit the syntax.


Ah. I think the practice is to treat the closure as being ended by any dedent that is lower than its first line. This specific case does come up with javascript's setTimeout, which takes a callback as its first argument and the timeout as the second. It usually seems to look like this:

    setTimeout ->
        doSomething()
        doSomethingElse()
    , 1000
I'm not terribly fond of this, personally, but it does solve the problem. I think in a language without a legacy you would just tend to avoid making callback arguments come before non-callback arguments and things would look a lot nicer.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: