11 ms·
which of the three Javascript examples is generated by? foo -> bar 'foo', -> 'bar' The point, is that Javascript is simple in demonstrating what are and a
by limeblack 15y ago
which of the three Javascript examples is generated by?
foo -> bar 'foo', -> 'bar'
The point, is that Javascript is simple in demonstrating what are and aren't functions because it has an ending delimiter.
CofeeScript isn't simple with anonymous function creation.
- jashkenas 15y agoFYI, function application wraps rightward to the end of the line, or the end of the block, so: foo -> bar 'foo', -> 'bar' Means: foo(-> bar('foo', -> 'bar')) But in any case, you wouldn't write it like that.
- limeblack 15y agoTelling the user to write something in two different ways, depending on the argument being passed, isn't simple. The point is an ending delimiter would greatly benefit CoffeScript. Although CofeeScript certainly has its perks, anonymous function creating isn't simple then Javascript.
- jashkenas 15y ago> Telling the user to write something in two different ways, > depending on the argument being passed, isn't simple. Huh? Sure it is. Fun fact: Any algorithm you can write in JavaScript can also be written as a single function, full of nested whiles, if/elses, fors, labels and breaks ... does that mean you should write your entire program as a single function? Nope. I'd like to think that CoffeeScript functions read better without an "ending delimiter": $('button').click -> alert "hello" # Or: app.get '/', (req, res) -> res.send 'Hello World' In any case, if you're interested in using CoffeeScript, but the lack of an ending delimiter is putting you off -- I encourage you to add one in your fork.
- fooandbarify 15y agoJeremy, I don't know much about CoffeeScript but I'm having a really hard time parsing your last example. Did you mean app.get '/', (req,res) -> res.send 'Hello World' ?
- jashkenas 15y agoI did indeed. Serves me right for commenting on the run.
- deleted 15y ago[deleted]
- dekz 15y agoYou do realise jash (the one you replied to) is the creator of coffeescript? There are horrible ways to write a lot of code, especially in whitespace based languages. What does petty comparisons like this bring to the argument?
- limeblack 15y agoYou can read the logic here: https://github.com/joyent/node/pull/2472#issuecomment-3378317 https://github.com/joyent/node/pull/2472#issuecomment-337831... Basically it would be a lot easier if a ending delimiter was the default for the language.
- leptons 15y agoIt would be a lot easier if done in javascript