Method definitions in classes/objects

Erik Arvidsson erik.arvidsson at gmail.com
Mon Oct 8 07:41:04 PDT 2012


On Sun, Oct 7, 2012 at 11:19 AM, Juan Ignacio Dopazo
<dopazo.juan at gmail.com> wrote:
> Hi!
>
> When checking what Traceur/TypeScript do when compiling method definitions I
> found both convert methods to assignments of an anonymous function.

It is crucial that you do not do assignment because assignment has
side effects, fails on non writable etc.

class B {
  set m(v) { throw Error() }
}

class C extends B {
  m() { }
}

> I was under the impression that methods would desugar to a named function
> with the same name as the property, but I checked the wiki and there is no
> reference to named functions. Has this been discussed? Is there consensus on
> anonymous/named?

It was agreed that methods would desugar to a named function. It
should be in the ES6 draft under Property Definition Evaluation but I
don't understand in which step that is described. Allen can probably
point out where propName gets added to scope.

-- 
erik


More information about the es-discuss mailing list