Shorter syntax for arrow function assignment

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

Shorter syntax for arrow function assignment

Brian Blakely
A prevalent pattern has emerged:

`export const foo = ()=> { };`

Taking a cue from short method syntax, this comes to mind as a possible improvement:

`export const foo() { };`

Even better if we assume const:

`export foo() { };`

That is delicious.  Thoughts?

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

Re: Shorter syntax for arrow function assignment

kai zhu
-1
this fails styleguide sanity-check.

we currently have 3 common styles of declaring functions:
1. foo = function () {...}
2. function foo () {...}
3. foo = () => {...}

does this extra 4th style offer anything new to justify making the
javascript language even less consistent than it already is?  i say
no.


On 10/25/17, Brian Blakely <[hidden email]> wrote:

> A prevalent pattern has emerged:
>
> `export const foo = ()=> { };`
>
> Taking a cue from short method syntax, this comes to mind as a possible
> improvement:
>
> `export const foo() { };`
>
> Even better if we assume const:
>
> `export foo() { };`
>
> That is delicious.  Thoughts?
>
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Shorter syntax for arrow function assignment

Brian Blakely
This syntax is shorter, easier to write, and arguably easier to read.  What else does it need to offer?

On Tue, Oct 24, 2017 at 12:48 PM, kai zhu <[hidden email]> wrote:
-1
this fails styleguide sanity-check.

we currently have 3 common styles of declaring functions:
1. foo = function () {...}
2. function foo () {...}
3. foo = () => {...}

does this extra 4th style offer anything new to justify making the
javascript language even less consistent than it already is?  i say
no.


On 10/25/17, Brian Blakely <[hidden email]> wrote:
> A prevalent pattern has emerged:
>
> `export const foo = ()=> { };`
>
> Taking a cue from short method syntax, this comes to mind as a possible
> improvement:
>
> `export const foo() { };`
>
> Even better if we assume const:
>
> `export foo() { };`
>
> That is delicious.  Thoughts?
>


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

Re: Shorter syntax for arrow function assignment

/#!/JoePea
It can be confusing because it is too similar to non-arrow functions. The arrow syntax is clear in meaning.

/#!/JoePea

On Tue, Oct 24, 2017 at 9:51 AM, Brian Blakely <[hidden email]> wrote:
This syntax is shorter, easier to write, and arguably easier to read.  What else does it need to offer?

On Tue, Oct 24, 2017 at 12:48 PM, kai zhu <[hidden email]> wrote:
-1
this fails styleguide sanity-check.

we currently have 3 common styles of declaring functions:
1. foo = function () {...}
2. function foo () {...}
3. foo = () => {...}

does this extra 4th style offer anything new to justify making the
javascript language even less consistent than it already is?  i say
no.


On 10/25/17, Brian Blakely <[hidden email]> wrote:
> A prevalent pattern has emerged:
>
> `export const foo = ()=> { };`
>
> Taking a cue from short method syntax, this comes to mind as a possible
> improvement:
>
> `export const foo() { };`
>
> Even better if we assume const:
>
> `export foo() { };`
>
> That is delicious.  Thoughts?
>


_______________________________________________
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: Shorter syntax for arrow function assignment

Peter Jaszkowiak
In reply to this post by kai zhu
It needs to offer more than two characters, and no confusing confliction with shorthand method syntax.

On Oct 24, 2017 10:48, "kai zhu" <[hidden email]> wrote:
-1
this fails styleguide sanity-check.

we currently have 3 common styles of declaring functions:
1. foo = function () {...}
2. function foo () {...}
3. foo = () => {...}

does this extra 4th style offer anything new to justify making the
javascript language even less consistent than it already is?  i say
no.


On 10/25/17, Brian Blakely <[hidden email]> wrote:
> A prevalent pattern has emerged:
>
> `export const foo = ()=> { };`
>
> Taking a cue from short method syntax, this comes to mind as a possible
> improvement:
>
> `export const foo() { };`
>
> Even better if we assume const:
>
> `export foo() { };`
>
> That is delicious.  Thoughts?
>
_______________________________________________
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: Shorter syntax for arrow function assignment

Brian Blakely
In reply to this post by /#!/JoePea
As arrow function const assignments become the norm and non-arrows the exception, allowing syntactical cruft to fall away makes sense to me.  It might be premature based on overall 2015 adoption, but I don't see this trend reversing.

On Tue, Oct 24, 2017 at 12:54 PM, /#!/JoePea <[hidden email]> wrote:
It can be confusing because it is too similar to non-arrow functions. The arrow syntax is clear in meaning.

/#!/JoePea

On Tue, Oct 24, 2017 at 9:51 AM, Brian Blakely <[hidden email]> wrote:
This syntax is shorter, easier to write, and arguably easier to read.  What else does it need to offer?

On Tue, Oct 24, 2017 at 12:48 PM, kai zhu <[hidden email]> wrote:
-1
this fails styleguide sanity-check.

we currently have 3 common styles of declaring functions:
1. foo = function () {...}
2. function foo () {...}
3. foo = () => {...}

does this extra 4th style offer anything new to justify making the
javascript language even less consistent than it already is?  i say
no.


On 10/25/17, Brian Blakely <[hidden email]> wrote:
> A prevalent pattern has emerged:
>
> `export const foo = ()=> { };`
>
> Taking a cue from short method syntax, this comes to mind as a possible
> improvement:
>
> `export const foo() { };`
>
> Even better if we assume const:
>
> `export foo() { };`
>
> That is delicious.  Thoughts?
>


_______________________________________________
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: Shorter syntax for arrow function assignment

Andrea Giammarchi-2
to me this `export foo() {}` makes sense only as shortcut for `export function foo() {}` and not as arrow, because arrow missing context and arguments will mislead everyone exporting a named function.

-1

On Tue, Oct 24, 2017 at 1:59 PM, Brian Blakely <[hidden email]> wrote:
As arrow function const assignments become the norm and non-arrows the exception, allowing syntactical cruft to fall away makes sense to me.  It might be premature based on overall 2015 adoption, but I don't see this trend reversing.

On Tue, Oct 24, 2017 at 12:54 PM, /#!/JoePea <[hidden email]> wrote:
It can be confusing because it is too similar to non-arrow functions. The arrow syntax is clear in meaning.

/#!/JoePea

On Tue, Oct 24, 2017 at 9:51 AM, Brian Blakely <[hidden email]> wrote:
This syntax is shorter, easier to write, and arguably easier to read.  What else does it need to offer?

On Tue, Oct 24, 2017 at 12:48 PM, kai zhu <[hidden email]> wrote:
-1
this fails styleguide sanity-check.

we currently have 3 common styles of declaring functions:
1. foo = function () {...}
2. function foo () {...}
3. foo = () => {...}

does this extra 4th style offer anything new to justify making the
javascript language even less consistent than it already is?  i say
no.


On 10/25/17, Brian Blakely <[hidden email]> wrote:
> A prevalent pattern has emerged:
>
> `export const foo = ()=> { };`
>
> Taking a cue from short method syntax, this comes to mind as a possible
> improvement:
>
> `export const foo() { };`
>
> Even better if we assume const:
>
> `export foo() { };`
>
> That is delicious.  Thoughts?
>


_______________________________________________
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: Shorter syntax for arrow function assignment

Michał Wadas
+1 for omitting function keyword between export and function name.

Declaring arrow functions without arrow in syntax - nope, nope, nope. 

On 24 Oct 2017 7:01 pm, "Andrea Giammarchi" <[hidden email]> wrote:
to me this `export foo() {}` makes sense only as shortcut for `export function foo() {}` and not as arrow, because arrow missing context and arguments will mislead everyone exporting a named function.

-1

On Tue, Oct 24, 2017 at 1:59 PM, Brian Blakely <[hidden email]> wrote:
As arrow function const assignments become the norm and non-arrows the exception, allowing syntactical cruft to fall away makes sense to me.  It might be premature based on overall 2015 adoption, but I don't see this trend reversing.

On Tue, Oct 24, 2017 at 12:54 PM, /#!/JoePea <[hidden email]> wrote:
It can be confusing because it is too similar to non-arrow functions. The arrow syntax is clear in meaning.

/#!/JoePea

On Tue, Oct 24, 2017 at 9:51 AM, Brian Blakely <[hidden email]> wrote:
This syntax is shorter, easier to write, and arguably easier to read.  What else does it need to offer?

On Tue, Oct 24, 2017 at 12:48 PM, kai zhu <[hidden email]> wrote:
-1
this fails styleguide sanity-check.

we currently have 3 common styles of declaring functions:
1. foo = function () {...}
2. function foo () {...}
3. foo = () => {...}

does this extra 4th style offer anything new to justify making the
javascript language even less consistent than it already is?  i say
no.


On 10/25/17, Brian Blakely <[hidden email]> wrote:
> A prevalent pattern has emerged:
>
> `export const foo = ()=> { };`
>
> Taking a cue from short method syntax, this comes to mind as a possible
> improvement:
>
> `export const foo() { };`
>
> Even better if we assume const:
>
> `export foo() { };`
>
> That is delicious.  Thoughts?
>


_______________________________________________
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


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

Re: Shorter syntax for arrow function assignment

Brian Blakely
In reply to this post by Andrea Giammarchi-2
I certainly understand the "misleading" perspective, but also consider ES5- function syntax to be deteriorating such that this shorthand would be wasted on it.

On Tue, Oct 24, 2017 at 1:01 PM, Andrea Giammarchi <[hidden email]> wrote:
to me this `export foo() {}` makes sense only as shortcut for `export function foo() {}` and not as arrow, because arrow missing context and arguments will mislead everyone exporting a named function.

-1

On Tue, Oct 24, 2017 at 1:59 PM, Brian Blakely <[hidden email]> wrote:
As arrow function const assignments become the norm and non-arrows the exception, allowing syntactical cruft to fall away makes sense to me.  It might be premature based on overall 2015 adoption, but I don't see this trend reversing.

On Tue, Oct 24, 2017 at 12:54 PM, /#!/JoePea <[hidden email]> wrote:
It can be confusing because it is too similar to non-arrow functions. The arrow syntax is clear in meaning.

/#!/JoePea

On Tue, Oct 24, 2017 at 9:51 AM, Brian Blakely <[hidden email]> wrote:
This syntax is shorter, easier to write, and arguably easier to read.  What else does it need to offer?

On Tue, Oct 24, 2017 at 12:48 PM, kai zhu <[hidden email]> wrote:
-1
this fails styleguide sanity-check.

we currently have 3 common styles of declaring functions:
1. foo = function () {...}
2. function foo () {...}
3. foo = () => {...}

does this extra 4th style offer anything new to justify making the
javascript language even less consistent than it already is?  i say
no.


On 10/25/17, Brian Blakely <[hidden email]> wrote:
> A prevalent pattern has emerged:
>
> `export const foo = ()=> { };`
>
> Taking a cue from short method syntax, this comes to mind as a possible
> improvement:
>
> `export const foo() { };`
>
> Even better if we assume const:
>
> `export foo() { };`
>
> That is delicious.  Thoughts?
>


_______________________________________________
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: Shorter syntax for arrow function assignment

T.J. Crowder-2
In reply to this post by Andrea Giammarchi-2
Agree with Andrea on this one. Method syntax (in an object initializer, in a `class`) creates a method (a non-arrow function with a [[HomeObject]] slot), not an arrow function. This looks just like method syntax. The absence of the arrow is too misleading.

I could see it as a shortcut for `export function foo() { }`, but not for `export const foo = () => { };`.

-- T.J. Crowder

On Tue, Oct 24, 2017 at 6:01 PM, Andrea Giammarchi <[hidden email]> wrote:
to me this `export foo() {}` makes sense only as shortcut for `export function foo() {}` and not as arrow, because arrow missing context and arguments will mislead everyone exporting a named function.

-1

On Tue, Oct 24, 2017 at 1:59 PM, Brian Blakely <[hidden email]> wrote:
As arrow function const assignments become the norm and non-arrows the exception, allowing syntactical cruft to fall away makes sense to me.  It might be premature based on overall 2015 adoption, but I don't see this trend reversing.

On Tue, Oct 24, 2017 at 12:54 PM, /#!/JoePea <[hidden email]> wrote:
It can be confusing because it is too similar to non-arrow functions. The arrow syntax is clear in meaning.

/#!/JoePea

On Tue, Oct 24, 2017 at 9:51 AM, Brian Blakely <[hidden email]> wrote:
This syntax is shorter, easier to write, and arguably easier to read.  What else does it need to offer?

On Tue, Oct 24, 2017 at 12:48 PM, kai zhu <[hidden email]> wrote:
-1
this fails styleguide sanity-check.

we currently have 3 common styles of declaring functions:
1. foo = function () {...}
2. function foo () {...}
3. foo = () => {...}

does this extra 4th style offer anything new to justify making the
javascript language even less consistent than it already is?  i say
no.


On 10/25/17, Brian Blakely <[hidden email]> wrote:
> A prevalent pattern has emerged:
>
> `export const foo = ()=> { };`
>
> Taking a cue from short method syntax, this comes to mind as a possible
> improvement:
>
> `export const foo() { };`
>
> Even better if we assume const:
>
> `export foo() { };`
>
> That is delicious.  Thoughts?
>


_______________________________________________
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



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

Re: Shorter syntax for arrow function assignment

Brian Blakely
In reply to this post by Michał Wadas
ICYMI: my stance is that ES5- functions are already outmoded - and are rapidly becoming the lesser-used option - so it would be a waste of a syntax win.

On Tue, Oct 24, 2017 at 1:11 PM, Michał Wadas <[hidden email]> wrote:
+1 for omitting function keyword between export and function name.

Declaring arrow functions without arrow in syntax - nope, nope, nope. 

On 24 Oct 2017 7:01 pm, "Andrea Giammarchi" <[hidden email]> wrote:
to me this `export foo() {}` makes sense only as shortcut for `export function foo() {}` and not as arrow, because arrow missing context and arguments will mislead everyone exporting a named function.

-1

On Tue, Oct 24, 2017 at 1:59 PM, Brian Blakely <[hidden email]> wrote:
As arrow function const assignments become the norm and non-arrows the exception, allowing syntactical cruft to fall away makes sense to me.  It might be premature based on overall 2015 adoption, but I don't see this trend reversing.

On Tue, Oct 24, 2017 at 12:54 PM, /#!/JoePea <[hidden email]> wrote:
It can be confusing because it is too similar to non-arrow functions. The arrow syntax is clear in meaning.

/#!/JoePea

On Tue, Oct 24, 2017 at 9:51 AM, Brian Blakely <[hidden email]> wrote:
This syntax is shorter, easier to write, and arguably easier to read.  What else does it need to offer?

On Tue, Oct 24, 2017 at 12:48 PM, kai zhu <[hidden email]> wrote:
-1
this fails styleguide sanity-check.

we currently have 3 common styles of declaring functions:
1. foo = function () {...}
2. function foo () {...}
3. foo = () => {...}

does this extra 4th style offer anything new to justify making the
javascript language even less consistent than it already is?  i say
no.


On 10/25/17, Brian Blakely <[hidden email]> wrote:
> A prevalent pattern has emerged:
>
> `export const foo = ()=> { };`
>
> Taking a cue from short method syntax, this comes to mind as a possible
> improvement:
>
> `export const foo() { };`
>
> Even better if we assume const:
>
> `export foo() { };`
>
> That is delicious.  Thoughts?
>


_______________________________________________
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



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

Re: Re: Shorter syntax for arrow function assignment

Dante Federici
In reply to this post by Brian Blakely
My major concern is this can be confusing with the "this" binding.
The object wrapping being the only difference between:
```
// Existing:
const x = {
  myFn() { }
};

// Proposed, with different meaning:
const myFn() { } // Why would "this" bind to myFn?
```
Omitting the arrow is a major -1 for me -- the whole point of "=>" is that it does not provide a "this" to the scope of the function body.

Also, you cannot implicitly omit the "const", as these are all valid:
```
export var symbol = ...
export let symbol = ...
export const symbol = ...
```

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

Re: Re: Shorter syntax for arrow function assignment

Brian Blakely
>Also, you cannot implicitly omit the "const"

Paving a cowpath, const has won named function assignment.

On Tue, Oct 24, 2017 at 1:16 PM, dante federici <[hidden email]> wrote:
My major concern is this can be confusing with the "this" binding.
The object wrapping being the only difference between:
```
// Existing:
const x = {
  myFn() { }
};

// Proposed, with different meaning:
const myFn() { } // Why would "this" bind to myFn?
```
Omitting the arrow is a major -1 for me -- the whole point of "=>" is that it does not provide a "this" to the scope of the function body.

Also, you cannot implicitly omit the "const", as these are all valid:
```
export var symbol = ...
export let symbol = ...
export const symbol = ...
```

_______________________________________________
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: Re: Shorter syntax for arrow function assignment

Dante Federici
In reply to this post by Brian Blakely
Another annoying thing JS has to deal with is:
```
// implicitly 'var'
someVar = 10;
```

So, something like:
```
myFn() {
}
```

Would be considered as:
```
var myFn = function() {
}
```

with what semantics exist now. Not best practices, but what is currently interpreted in the language.

I'd 100% agree that, as a shorthand, this is nice:
```
myFn() { }
const myFn = () => {}
```

Which is what I mean. But I'm not the full implementation of JavaScript.

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

Since we're discussing arrow functions and syntax...

Michael Rosefield
In reply to this post by Dante Federici
I like arrow functions, and sometimes the only reason I don't use them is because I need this-binding.

So I, personally would like a variant that uses the CoffeeScript -> syntax that is precisely like => except that it uses traditional this-binding. The only 2 issues I can see are:

* adding more syntax to the language
* could the concise form bind this? Would, say `const foo = obj -> Object.assign(obj, this.bar)` work, if then used, say, as follows: `const baz = { bar: { /*whatever*/ } }; foo.call(baz, { /* something */ })`

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

Re: Re: Shorter syntax for arrow function assignment

Brian Blakely
In reply to this post by Dante Federici
At current, sans an explicit assignment, the pragma `foo() {...}` should throw.

On Tue, Oct 24, 2017 at 1:26 PM, dante federici <[hidden email]> wrote:
Another annoying thing JS has to deal with is:
```
// implicitly 'var'
someVar = 10;
```

So, something like:
```
myFn() {
}
```

Would be considered as:
```
var myFn = function() {
}
```

with what semantics exist now. Not best practices, but what is currently interpreted in the language.

I'd 100% agree that, as a shorthand, this is nice:
```
myFn() { }
const myFn = () => {}
```

Which is what I mean. But I'm not the full implementation of JavaScript.

_______________________________________________
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: Since we're discussing arrow functions and syntax...

kai zhu
In reply to this post by Michael Rosefield
-1
this is user-hostile to c++ programmers writing wasm / node-native
modules, when they context-switch c++ <-> javascript

On 10/25/17, Michael Rosefield <[hidden email]> wrote:

> I like arrow functions, and sometimes the only reason I don't use them is
> because I need this-binding.
>
> So I, personally would like a variant that uses the CoffeeScript -> syntax
> that is precisely like => except that it uses traditional this-binding. The
> only 2 issues I can see are:
>
> * adding more syntax to the language
> * could the concise form bind this? Would, say `const foo = obj ->
> Object.assign(obj, this.bar)` work, if then used, say, as follows: `const
> baz = { bar: { /*whatever*/ } }; foo.call(baz, { /* something */ })`
>
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Since we're discussing arrow functions and syntax...

Andrea Giammarchi-2
I was for it before ES6 and they told me it was "an arrow too far"

however, object methods shortcuts are better than arrows and methods is the only place where you need `this`

On Tue, Oct 24, 2017 at 2:34 PM, kai zhu <[hidden email]> wrote:
-1
this is user-hostile to c++ programmers writing wasm / node-native
modules, when they context-switch c++ <-> javascript

On 10/25/17, Michael Rosefield <[hidden email]> wrote:
> I like arrow functions, and sometimes the only reason I don't use them is
> because I need this-binding.
>
> So I, personally would like a variant that uses the CoffeeScript -> syntax
> that is precisely like => except that it uses traditional this-binding. The
> only 2 issues I can see are:
>
> * adding more syntax to the language
> * could the concise form bind this? Would, say `const foo = obj ->
> Object.assign(obj, this.bar)` work, if then used, say, as follows: `const
> baz = { bar: { /*whatever*/ } }; foo.call(baz, { /* something */ })`
>
_______________________________________________
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: Re: Since we're discussing arrow functions and syntax...

Dante Federici
In reply to this post by Michael Rosefield
I'd check out the bind and pipe operators:

But my problems are `=>` and `->` would really lead to some sadness.

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

Re: Re: Shorter syntax for arrow function assignment

Andrea Giammarchi-2
In reply to this post by Brian Blakely
functions are already outmoded

I don't know where you come from but to me:

```js
// this ain't outmoded at all
const obj = {
  method() { return this === obj; }
};

// this ain't outmoded at all
class Any {
  method() { return this instanceof Any; }
}
```

And a module that provides mixins is definitively not outmoded at all
```js
export method() {
  return this !== undefined;
};
```

Omitting the arrow is everything but a syntax win here.

Regards




On Tue, Oct 24, 2017 at 2:32 PM, Brian Blakely <[hidden email]> wrote:
At current, sans an explicit assignment, the pragma `foo() {...}` should throw.

On Tue, Oct 24, 2017 at 1:26 PM, dante federici <[hidden email]> wrote:
Another annoying thing JS has to deal with is:
```
// implicitly 'var'
someVar = 10;
```

So, something like:
```
myFn() {
}
```

Would be considered as:
```
var myFn = function() {
}
```

with what semantics exist now. Not best practices, but what is currently interpreted in the language.

I'd 100% agree that, as a shorthand, this is nice:
```
myFn() { }
const myFn = () => {}
```

Which is what I mean. But I'm not the full implementation of JavaScript.

_______________________________________________
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
12