Skip to content

Syntax for functions without implicit returns? #1812

New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
reissbaker opened this issue Oct 29, 2011 · 5 comments
Closed

Syntax for functions without implicit returns? #1812

reissbaker opened this issue Oct 29, 2011 · 5 comments

Comments

@reissbaker
Copy link

This may be a stretch, but it'd be pretty nice in some cases to have function syntax that would make it easier to not return anything. In several libraries (Vows is one that immediately comes to mind, but implicit returns can trip up jQuery code, too), returning from a function means something different than not returning from a function, and having to write the empty return statements everywhere is awkward and can lead to bugs that aren't immediately obvious.

Something like this would make me really happy:

(arg) -/> fn() # does not return anything
(arg) -> fn() # returns the result of fn()

What I like about the -/> syntax is that it could work both for the current unbound syntax and for the bound version, and it does exactly what it looks like -- it cuts off and suppresses the returned value.

@michaelficarra
Copy link
Collaborator

I don't think this suggestion addresses anything that was not covered in #899. If you have anything you feel adds to that discussion, post it there. Closing.

@TrevorBurnham
Copy link
Collaborator

@reissbaker FWIW, I heartily favor this syntax; but Jeremy prefers the explicit return or undefined that's currently required.

@reissbaker
Copy link
Author

Yikes, my bad -- I searched for "implicit returns," but I should've just checked returns in general.

@michaelficarra
Copy link
Collaborator

And FWIW, I agree with Jeremy. But I also feel that loops shouldn't be comprehensions unless we explicitly state we want it to be a comprehension, such as enclosing it in [] (Python).

@reissbaker
Copy link
Author

Heh. FWIW, I agree that loops shouldn't be implicit comprehensions, too. Oh well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants