extends keyword instead of <superclass ... >

Allen Wirfs-Brock allen at wirfs-brock.com
Sun Mar 27 16:39:41 PDT 2011


Consistently extending object literals into "class" literals was one of the goals of this particular design but that goal isn't a requirement.  At the latest TC39 meeting some participants expressed an opinion that the prototype specification for an object literal should go outside of the brackets.  http://wiki.ecmascript.org/doku.php?id=strawman:proto_operator presents one possible design for that approach. If object literals designs evolve in this or other directions then it may be less important to maintain consistency between object literals and class declarations.

Another thing I haven't seen mentioned on this thread, is that my class declaration proposal  supported both proto: and superclass: as alternatives metaproperties with different semantics.  There seems to be valid use cases for each.  It may not be necessarily to have both but in exploring alternatives that possibility should continue to be considered.

On Mar 27, 2011, at 1:05 PM, Brendan Eich wrote:

> Do we really need to look different yet still have bones that look so familiar? I am not convinced.
> 
> The strongest case for extending initialiser syntax is that it is "nearly declarative" today. That suggests strongly making the extension fully declarative, i.e., not usable as an expression. And that, all else equal (never is, but:) says to consider class D extends B {...}. My 2 cents.
> 

I don't think "declarative" should not be equated with "not usable as an expression " or introduces a lexical binding.  When I say declarative I mean  a non-constructive (or non-imperative) definition of the desired value.  3 is declarative, 2+1 isn't.  Some people describe this difference as "what, not how". Both function declarations and function expressions are both declarative definitions of functions even though one creates a local binding and the other can be used as an expression.  In my proposal, the same distinction was applied to class definitions.  There was both a statement and expression form, largely for consistency with functions.  I don't think this distinction has much, at all, to do with the syntax for specifying the superclass or prototype.

Allen

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110327/c8ceea21/attachment.html>


More information about the es-discuss mailing list