John Barton (2015-06-03T13:46:19.000Z)
On Wed, Jun 3, 2015 at 1:27 AM, Benjamin Gruenaum <benjamingr at gmail.com>
wrote:

> Am I missing something obvious in `super((resolve, reject) => this)` ?
>
> First of all, it makes perfect sense for `this` not work work before super
> has been called - and it has not been called yet.
>

Rather than starting off by claiming the restriction on "this" before
"super()" makes perfect sense, let's be honest that lots of normal
developers will be tripped up by this restriction. "this" is used a
reference throughout class code: it makes "perfect sense" to use it in a
constructor.  Passing extended-class-specific values to super() is exactly
what super() does. Thus using "this" in a constructor before calling
super() is entirely natural in light of other experience with the
language.  Our inability to support "this" before super() is unfortunate,
so let's sympathize and encourage people to understand.



> I think that the crux is that the promise constructor runs _synchronously_
> so when you pass it `this` it has not finished running yet.
>
> Of course, the workaround as domenic has pointed is to extract `resolve`
> and `reject` from the `super` call since it is synchronous.
>
> (also I'm assuming you're not really mapping `(resolve, reject)` to
> `this`? `this` is an object and the promise constructor ignores return
> values anyway, you might as well pass a no-op in.)
>
>
>
>
> _______________________________________________
> 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/20150603/faf2201f/attachment.html>
d at domenic.me (2015-06-08T00:05:17.829Z)
On Wed, Jun 3, 2015 at 1:27 AM, Benjamin Gruenaum <benjamingr at gmail.com> wrote:

> Am I missing something obvious in `super((resolve, reject) => this)` ?
>
> First of all, it makes perfect sense for `this` not work work before super
> has been called - and it has not been called yet.
>

Rather than starting off by claiming the restriction on "this" before
"super()" makes perfect sense, let's be honest that lots of normal
developers will be tripped up by this restriction. "this" is used a
reference throughout class code: it makes "perfect sense" to use it in a
constructor.  Passing extended-class-specific values to super() is exactly
what super() does. Thus using "this" in a constructor before calling
super() is entirely natural in light of other experience with the
language.  Our inability to support "this" before super() is unfortunate,
so let's sympathize and encourage people to understand.