satyr / coco

Unfancy CoffeeScript

Home Page:http://satyr.github.com/coco/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature: void return

edef1c opened this issue · comments

commented

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

commented

something like EXPRESSION; return ?

EXPRESSION; return ?

This, or if you must: return void expression

commented

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.

commented

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).

commented

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)

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.