satyr / coco

Unfancy CoffeeScript
http://satyr.github.com/coco/
MIT License
498 stars 48 forks source link

Feature: void return #218

Closed edef1c closed 6 years ago

edef1c commented 11 years ago

A void return a la JS's return void EXPRESSION would rock. Maybe !return EXPRESSION or return! EXPRESSION.

vendethiel commented 11 years ago

something like EXPRESSION; return ?

satyr commented 11 years ago

EXPRESSION; return ?

This, or if you must: returnvoidexpression

edef1c commented 11 years ago

That works, though not quite idiomatic. I do if (cond) return void expr a lot in JS, for short-circuit logic. return! expr if cond would be awesome.

vendethiel commented 11 years ago

That's actually a more common patrern than I first thought, reading node code. if err then cb err; return is what I'd use (return void expr gets aci => return void, expr; and I'm not sure I'd like to see more hushing syntax).

edef1c commented 11 years ago

return cb err if err is very common, along with a variety of similar async dispatches. return! expr could compile to expr; return (return void is the best we can do when writing JS straight, but we have the opportunity to improve here)

satyr commented 11 years ago

Hmph. True that it is another case forced more verbose than JS.

Options:

  1. Reuse the hushing analogy as proposed: !return (and not return)
  2. Treat return void (currently useless being the same as just return) as one operator.