James Long (2013-12-10T00:39:07.000Z)
If you have an inner function that calls `super`, Traceur keeps track
of the outer "this" and makes sure to call it with that. TypeScript
does not do this. Is this correct?

```
class Bar extends Foo {
    nestedFunction() {
        function run() {
            return super.getX();
        }

        return run();
    }
}
```

This code compiles to:

```
    nestedFunction: function() {
      var $__0 = this;
      function run() {
        return $__superCall($__0, $__proto, "getX", []);
      }
      return run();
    }
```

where `$__superCall` basically just does $__proto["getX"].apply($__0,
[]). But note that it saved the outer `this` in $__0 and called it
with that.

On Mon, Dec 9, 2013 at 4:10 PM, Erik Arvidsson <erik.arvidsson at gmail.com> wrote:
> TS is known to get this wrong in the name of simplicity.
>
> Traceur gets it right inside class bodies. We do not support toMethod (not
> even sure if this is doable).
>
> https://github.com/google/traceur-compiler/blob/master/test/feature/Classes/SuperChangeProto.js
> http://goo.gl/0kV4ts
>
>
>
>
> On Mon, Dec 9, 2013 at 12:46 PM, Juan Ignacio Dopazo <jdopazo at yahoo-inc.com>
> wrote:
>>
>> On Mon, Dec 9, 2013 at 2:36 PM, Till Schneidereit
>> <till at tillschneidereit.net> wrote:
>>>
>>> You could also check the output of Traceur and TypeScript. I don't know
>>> how close either of them are to implementing the exact semantics of ES6
>>> classes, but I'm sure it'll be helpful in any case.
>>>
>>
>> Yup. See
>> http://www.typescriptlang.org/Playground/#src=class%20Person%20%7B%0A%09private%20name%3A%20string%3B%0A%09%0A%09constructor(name)%20%7B%0A%09%09this.name%20%3D%20name%3B%0A%09%7D%0A%09%0A%09say(message%3A%20string)%20%7B%0A%09%09return%20this.name%20%2B%20'%20says%3A%20'%20%2B%20message%3B%0A%09%7D%0A%7D%0A%0Aclass%20Pirate%20extends%20Person%20%7B%0A%09constructor(name)%20%7B%0A%09%09super('Captn%5C'%20'%20%2B%20name)%3B%0A%09%7D%0A%09%0A%09say(message)%20%7B%0A%09%09return%20super.say(message%20%2B%20'%20Arrr!')%3B%0A%09%7D%0A%7D
>>
>>  - Juan
>>
>>
>> On Monday, December 9, 2013 2:37 PM, Till Schneidereit
>> <till at tillschneidereit.net> wrote:
>> You could also check the output of Traceur and TypeScript. I don't know
>> how close either of them are to implementing the exact semantics of ES6
>> classes, but I'm sure it'll be helpful in any case.
>>
>>
>> On Mon, Dec 9, 2013 at 6:28 PM, James Long <longster at gmail.com> wrote:
>>
>> I read Allen's email wrong, thought it implied `this` was lexically
>> scoped (which I know is not true. very little sleep at an airport...).
>>
>> I'll keep digging through the spec, but if someone has a quick example
>> what ES5 code I could compile to for roughly the same semantics, that
>> would be helpful. From what I understand, you're saying that `super`
>> is lexically scoped to the `class` that is defined so I can statically
>> compile it out to something like `Foo.prototype.method` if `Foo` is
>> the parent class. Anyway, no need to trail on about this, I should
>> just RTFS.
>>
>> - James
>>
>> On Mon, Dec 9, 2013 at 11:23 AM, Brendan Eich <brendan at mozilla.com> wrote:
>> > OnMon, Dec 9, 2013  at 10:22 AM,  Allen Wirfs-Brock
>> >
>> > <allen at wirfs-brock.com>  wrote:
>> >
>> >> >  super is lexically scoped
>> >
>> >
>> > This is true.
>> >
>> >
>> >
>> > James Long wrote:
>> >>
>> >> So essentially super is an alias for `Object.getPrototypeOf(this)` ?
>> >
>> >
>> > But |this| is not lexically scoped, so your question's answer must be
>> > "no".
>> >
>> > /be
>> _______________________________________________
>> 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
>>
>>
>>
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>>
>
>
>
> --
> erik
domenic at domenicdenicola.com (2013-12-10T02:50:12.755Z)
If you have an inner function that calls `super`, Traceur keeps track
of the outer "this" and makes sure to call it with that. TypeScript
does not do this. Is this correct?

```js
class Bar extends Foo {
    nestedFunction() {
        function run() {
            return super.getX();
        }

        return run();
    }
}
```

This code compiles to:

```js
    nestedFunction: function() {
      var $__0 = this;
      function run() {
        return $__superCall($__0, $__proto, "getX", []);
      }
      return run();
    }
```

where `$__superCall` basically just does `$__proto["getX"].apply($__0, [])`. But note that it saved the outer `this` in `$__0` and called it with that.