Make method semantic identical in classes and literals

Herby Vojčík herby at
Tue Jan 3 12:24:12 PST 2012


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, 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, this is 

  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 

(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

More information about the es-discuss mailing list