Make method semantic identical in classes and literals

Allen Wirfs-Brock allen at wirfs-brock.com
Wed Jan 4 15:13:40 PST 2012


As it stands right now there are still other more significant outstanding issues relating to both proposals that need to be addressed. As those get resolved we will make then as consistent with each other as makes sense.  I think there is wide agreement that "methods" should be should be non-enumerable. There may be less agreement on whether they should be non-writable or non-configurable.

Allen


On Jan 4, 2012, at 4:11 AM, Herby Vojčík wrote:

> It seems this is a bug in http://wiki.ecmascript.org/doku.php?id=harmony:object_literals. In full proposal of object literal (http://wiki.ecmascript.org/doku.php?id=harmony:concise_object_literal_extensions), this is written:
> 
> If a property definition has the form of a FunctionDeclaration without the keyword function it is a non-enumerable data property definition whose name is the function name.
> 
> So it is non-enumerable, writable and configurable, as generally presumed for methods.
> Could it be fixed?
> 
> Herby
> 
> -----Pôvodná správa----- From: Herby Vojčík
> Sent: Tuesday, January 03, 2012 9:24 PM
> To: es-discuss at mozilla.org
> Subject: Make method semantic identical in classes and literals
> 
> Hello,
> 
> overall I believe in making classes and literals as close as possible. I
> think at least semantics of things they have in common should be identical.
> 
> In http://wiki.ecmascript.org/doku.php?id=harmony:classes, this is written:
> 
> By default, data properties define enumerable prototype properties while
> method members define non-enumerable prototype properties. Members of
> non-const classes default to writable and configurable. Member adjectives,
> if present, override the default attributes of the property being defined.
> 
> (I take the liberty to treat const classes as special case, so) for
> (general) non-const classes, method are non-enumerable, configurable,
> writable. Declaring the method itself const (whatever syntax is adopted)
> probably changes it to non-configurable and non-writable.
> 
> I deem this semantics as the right one. We are in dynamic language and want
> to have our methods changeable, but non-enumerable is very nice property of
> a method. And if taking the case of static away for a moment, class is not
> any special thing: we can look at it as the literal describing the class's
> prototype object (which it, sort-of, does).
> 
> In http://wiki.ecmascript.org/doku.php?id=harmony:object_literals, this is
> written:
> 
> If a property definition has the form of a FunctionDeclaration without the
> keyword function it is a non-enumerable, non-writable, non-configurable data
> property definition whose name is the function name. This is called a method
> definition.
> 
> (For data (not methods), the literal semantics is the same as for class,
> but) for methods, object literal extension treats method as fixed. I believe
> they should be non-enumerable, but writable and configurable, and only
> changed to fixed when explicitly stated as const (whetever syntax is
> adopted), so the semantics is the same as it is for classes.
> 
> What do you think?
> 
> Thanks, Herby
> 
> _______________________________________________
> 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
> 



More information about the es-discuss mailing list