new instantiation design alternatives

Claude Pache claude.pache at gmail.com
Fri Sep 12 12:47:43 PDT 2014


Le 12 sept. 2014 à 17:26, Allen Wirfs-Brock <allen at wirfs-brock.com> a écrit :

> 
> 
> Another possibility that we've considered is to tag non-auto-allocating constructors in their declaration header  For example:
> 
> constructor() new {...}
> 
> function foo() new {...}
> 
> But, overall, we were trying to minimize syntactic embellishments and bikesheding opportunities. 
> 

The visual clue may be almost already there: According to the second variant, an `extends` clause on the class indicates that there is no auto-allocation (unless the constructor is completely left out, of course). And an absence of `extends` indicates that there is auto-allocation in most cases; it just remains to force to write `Base extends Function.prototype` in the rarer case one want allocate `this` manually. — But well, it is mostly personal taste, just like the * on generator functions.

—Claude



More information about the es-discuss mailing list