Pseudo headless arrows

Joris van der Wel joris at jorisvanderwel.com
Fri Apr 22 12:36:53 UTC 2016


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
> @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.
>
> /fm
>
> On Thu, Apr 21, 2016 at 7:44 PM, John Lenz <concavelenz at gmail.com> wrote:
>
>> _=>{} 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 <http://bterlson.github.io/headless-arrows/>.
>>
>> /fm
>>
>> On Thu, Apr 21, 2016 at 3:48 PM, Peter van der Zee <ecma at qfox.nl> wrote:
>>
>>> <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.
>>>
>>> - peter
>>> _______________________________________________
>>> es-discuss mailing list
>>> es-discuss at mozilla.org
>>> https://mail.mozilla.org/listinfo/es-discuss
>>>
>>
>>
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160422/3e2b263f/attachment.html>


More information about the es-discuss mailing list