using Private name objects for declarative property definition.

Brendan Eich brendan at mozilla.com
Mon Jul 11 10:41:11 PDT 2011


On Jul 11, 2011, at 10:25 AM, Allen Wirfs-Brock wrote:

> I don't think we or anybody else has really explored the extensibility implications of generator functions so it isn't surprising that there have been no requests.

We certainly have explored generators (extensibility is not a good in itself) since 2006. Multiple libraries on github use them.


> Certainly there is no need to add any new globals to support a distinct prototype for generator functions. Strictly speaking there wouldn't even have to be a property on Function to access it as it would be a built-in object that is accessed internally when a generator is created.  However, I do think it would be useful make it accessible via something like Function.generatorPrototype.   I don't see that adding such a property as undesirable pollution.

We're still trying to get isFoo conventions in order. Why add another (first-of or one-off) built-in prototype convention?

I'm going to stick with YAGNI and when in doubt, leave it out. Generators win to the extent that they are functions with the least shallow continuation semantics on top that work.


>> The method allows object-detection, which helps. It's ad-hoc but web JS has versioned itself based on object detection far better than on other, _a priori_ grand plans (Accept: headers, e.g.).
> 
> Function.generatorPrototype as described above would also support object-detection.
> 
> In general, how far to you think we can push a "all new features have to be object-detectable" requirement.  Do we need to be able to object-detect <|.

It's easy to go overboard. Developers do not detect at fine grain to handle insane or never-shipped combinations. The combinatorics explode, and reality is that browsers support feature cohorts that are fairly chunky.


>  How about rest and spread, or de-structuring?  We are going to use non-eval detectability as a ECMAScript extension design criteria then maybe we do need a less ad-hoc scheme for feature detection.  It wouldn't have to be all that grand...

Even less grand ones such as the DOM's (http://www.w3.org/TR/DOM-Level-3-Core/core.html#DOMFeatures) are failures.

/be


More information about the es-discuss mailing list