David Herman wrote:
On Mar 20, 2012, at 6:59 PM, Allen Wirfs-Brock wrote:

On Mar 20, 2012, at 11:55 AM, David Herman wrote:

My only syntactic quibble: `constructor` is so inconveniently long.
I've argued in the past for `new` as special syntax in class bodies
that indicates a constructor.

Well, it /is/ defining the value of the constructor property. New
syntax (eg, new) could always be added latter. I don't think we should
risk derailing on it now.

Well, hang on now. The 'constructor' syntax is not "just the constructor
property." It still carries special status; the semantics of a class
says "look for the property called 'constructor' and make that the
[[Call]] and [[Construct]] behavior of the class."

Regardless of whether we spell it 'constructor' or 'new' it requires
special semantics that says "there's one distinguished method form in
the body that determines the constructor of the class." The question is
how we spell that. This is 99.9% a surface syntax question. Tou could
argue that spelling it 'new' should define a ["new"] method, or a
["new"] method and a ["constructor"] method, or just a ["constructor"]
method. If the latter, it's semantically *identical* to spelling it
'constructor'. But even if we chose one of the other two alternatives,
the semantic differences here are minor, and the ergonomics of the
syntax matter.

One possibility is to use this:

class Foo extends Bar {
  @(...) { ... } // constructor
  @x(...) {...} // method with private name x
  die(...) {...} // method with public name
}

The @() {} syntax embraces the fact that 'it is a special case thing'. It in fact mimics as 'a method with private name ""' which could be read as 'something inherently special for the class, so that it is stored under default private slot' (there is nothing like 'default private slot', I know, I'm just showig possible readability of it), that is, its constructor (hopefully at least someone understands what I mean).

Look, it won't be the end of the world if we go with 'constructor'. This
particular question won't derail classes. But let's not tax the
ergonomics for what would be either a tiny or even non-existent semantic
difference.

...

Dave

Herby
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to