Pseudo headless arrows
The ==>
token would look like a new operator, which developers would have
to look up in order to know exactly what it does. It is more confusing than
helpful, IMHO.
Also ==>x
has the same length as _=>x
, the latter not introducing any
new syntax (although it does employ an ugly unused identifier).
By the way, this may be of interest to you: Headless Arrow Functions proposal bterlson.github.io/headless-arrows.
_=>{} is a function that takes one param and is not equivalent to ()=>{}.
Some test frameworks inspect the function and care about the difference. On Apr 21, 2016 3:34 PM, "Fabrício Matté" <ultcombo at gmail.com> wrote:
The ==>
token would look like a new operator, which developers would have
to look up in order to know exactly what it does. It is more confusing than
helpful, IMHO.
Also ==>x
has the same length as _=>x
, the latter not introducing any
new syntax (although it does employ an ugly unused identifier).
By the way, this may be of interest to you: Headless Arrow Functions proposal bterlson.github.io/headless-arrows.
@John: Good point.
IIRC, Mocha was (is?) one of such test frameworks that inspect the
function's length
property in order to determine whether the author
intends the test to be run asynchronously (i.e. the first argument receives
a function that must be called when the test is done).
Whether that is a good practice is questionable, however.
Three equals used outside of strict equality might take some getting used
to var fn ===> x
I like that Headless Arrow Function proposal (bterlson.github.io/headless-arrows).
doSomethingAsync(=> console.log('done'))
Yes, that is still how mocha does things. Mocha is not the best example
though, because it is not compatible with arrow functions. Mocha uses
this
to expose extra functions to your test case. (I always use a wrapper
around mocha to avoid these issues)
Subject: Re: Pseudo headless arrows
<searched for it><excuses if>
There are two ways of writing argument-less arrows;
() => x;
_ => x;
(Where
_
can be any identifier, of course.) I understand why we can't drop the head entirely so if we're forced to type anything at all, anyways, why not at least make it simpler by pressing two different keys instead of three/four:==> x;
I don't believe this leads to syntactical problems anywhere, not even with arrow functions themselves and it's future proof for at least the cases I'm aware of.
It's a minor addition but I think it's much nicer than either of the two alternatives we currently have, which lead to a lot of inconsistencies (it's spaces and tabs all over again).
Semantics are the same otherwise as
() => x
would be.