Pseudo headless arrows

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Pseudo headless arrows

Peter van der Zee
<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
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Pseudo headless arrows

Fabrício Matté
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.

/fm

On Thu, Apr 21, 2016 at 3:48 PM, Peter van der Zee <[hidden email]> 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
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Pseudo headless arrows

John Lenz-4

_=>{} 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é" <[hidden email]> 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.

/fm

On Thu, Apr 21, 2016 at 3:48 PM, Peter van der Zee <[hidden email]> 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
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Pseudo headless arrows

Fabrício Matté
@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 <[hidden email]> 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é" <[hidden email]> 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.

/fm

On Thu, Apr 21, 2016 at 3:48 PM, Peter van der Zee <[hidden email]> 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
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss



_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Pseudo headless arrows

Michael Theriot
In reply to this post by Peter van der Zee
Three equals used outside of strict equality might take some getting used to `var fn ===> x`

On Thu, Apr 21, 2016 at 1:48 PM, Peter van der Zee <[hidden email]> 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
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Pseudo headless arrows

#!/JoePea
I like that Headless Arrow Function proposal
(http://bterlson.github.io/headless-arrows).

```js
doSomethingAsync(=> console.log('done'))
```

On Thu, Apr 21, 2016 at 5:02 PM, Michael Theriot
<[hidden email]> wrote:

> Three equals used outside of strict equality might take some getting used to
> `var fn ===> x`
>
> On Thu, Apr 21, 2016 at 1:48 PM, Peter van der Zee <[hidden email]> 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
>> [hidden email]
>> https://mail.mozilla.org/listinfo/es-discuss
>
>
>
> _______________________________________________
> es-discuss mailing list
> [hidden email]
> https://mail.mozilla.org/listinfo/es-discuss
>
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Pseudo headless arrows

Joris van der Wel
In reply to this post by Peter van der Zee
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 <[hidden email]> 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é" <[hidden email]> 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.

/fm

On Thu, Apr 21, 2016 at 3:48 PM, Peter van der Zee <[hidden email]> 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
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss





_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss