-
Notifications
You must be signed in to change notification settings - Fork 48
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
Change the auto-return hushing syntax to a literal !-> #189
Comments
I believe it was made for this kind of case : |
What does |
|
I understood that part, but nothing about that effects hushing auto-return.
is still unambiguous. |
Needs {up,down}-votes.
That leaves out Avoiding symbol-bikeshed was one of the reasons to choose the current syntax. |
True, which is another reason I didn't like More succinctly, here are my arguments for a literal
And the full list of changes are:
I'm actually less sure about |
Not sure about |
👍 for unified |
|
I support this, though I feel it should be |
Whenever I start out with a hushed function
And then want to add a parameter, I usually end up doing this:
Which, unlike
(e) -> ....
, actually compiles to:This is--given how auto-return hushing works--how that code should compile, but I'd much rather it compile to what I expected, and I've been bitten enough times by it to care.
Proposal
Let the literal
!->
define a function without auto-return:In the same way
->
defines auto-returned functions.Why
I think of
!->
as analogous to the ruby convention of appending!
to functions that mutate in place, e.g.array.uniq!
;!->
defines functions that usually change state, not return values.But since
!->
is reallynot ->
, a hushed function with arguments becomes!(args) ->
, which loses most of that distinction.Using the english form of hushing also reads really strangely:
With a literal
!->
marking hushed functions instead, there's no chance of a confusing-lookingnot
being used, nor is there a break in muscle memory when changing-> it.stuff
to(thing) -> thing.stuff
or!-> it.method!
to(thing) !-> thing.method!
.For named functions, the literal
function!
could be used unambiguously:Furthermore, this change doesn't have to immediately break backwards compatability, since
not <fn literal>
still would otherwise evaluate to a uselessfalse
. The old hushing method could be deprecated while still introducing the new hushing literals.Other thought is that the literal could instead be
!>
, but that loses the distinctive arrow look of regular->
.The text was updated successfully, but these errors were encountered: