new instantiation design alternatives

Brendan Eich brendan at mozilla.org
Mon Sep 15 10:20:09 PDT 2014


Andreas Rossberg wrote:
> Well, regarding this particular aspect, the wider curly braces family
> doesn't have a consistent opinion. Our current design is following
> Java more closely than C++, which I think is fine (modulo dubious
> defaults). C++ needed the special syntax primarily because of its
> rather crazy initialization vs assignment story.

You're right, it's the grand-parent I was thinking of (C++) but Kevin 
mentioned C# as well (tough younger brother of Java :-P).

> If we were to go with a C++ like solution, we should refrain from
> abusing colon, though. It should be "constructor(x) extends super(x+1)
> {}".

Nice!

> Want to safe the colon for type annotations.:)

Someone building a compile-to-JS language (not LLJS) pointed out to me 
what LLJS already did: C-style `type declarator` annotations, with [no 
LineTerminator here] in between.

Seems doable at a glance in ECMA-262's grammar, provided declarator 
doesn't start sprouting C-like leading asterisk or left parenthesis. The 
trade-off is greater conciseness vs.colon annotation syntax, and no 
constraints from the market (even if only in developers' brains) due to 
TypeScript.

(Yeah, Dart-like -- why not?)

/be


More information about the es-discuss mailing list