Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Allow "1:y, 0:x" literal argumentsyntax #2911

Closed
jamesonquinn opened this Issue Apr 5, 2013 · 3 comments

Comments

Projects
None yet
4 participants

This is pure sugar, but it would sometimes be awfully nice to say, for instance:

setTimeout 1:1000, 0:->
  console.log "you are one second older now"

instead of doing silly comma/indent acrobatics to make it work.

Owner

jashkenas commented Apr 5, 2013

Ha ha.

7:write 6:and 8:something 0:That's 9:readable 1:a 3:way 2:ridiculous 4:to 5:try ;)

@jashkenas jashkenas closed this Apr 5, 2013

Contributor

epidemian commented Apr 5, 2013

Agreed with @jashkenas here. The problem with functions like setTimeout or Array#reduce is mostly poor library design. I don't think it's good for CS to include new syntax just to make badly designed libraries more usable.

Also, there are other ways to make this readable:

printMessage = -> console.log "you are one second older now"
setTimeout printMessage, 1000

Besides, another problem would be that the proposed syntax clashes with existing syntax 😃

Collaborator

michaelficarra commented Apr 5, 2013

flip = (fn) -> -> fn.apply this, [].reverse.call(arguments)
flippedSetTimeout = flip setTimeout
flippedSetTimeout 1000, ->
  console.log 'you are one second older now'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment