Brendan: > I'm abusing Object as ES5 does, but harder, to avoid polluting the global > object. I'm supposing Object.implementation could be useful for other > properties than the supports method. This reads well enough, although its a > bit long-winded altogether (but individual names are short enough). > Comments?
Have i got the wrong end of the stick on this... With ES6 i thought modules would provide some namespace functionality. eg import meta // or whatever the syntax is meta.supports("yield") And a home for any ast functionality: import ast let x = ast.parse("3 + 3") It's interesting that Lua puts its yield/coroutine functionality in a module: coroutine.yield() It's function format but at least it's not necessary to worry about the global namespace (with modules). On Mon, May 18, 2009 at 8:13 PM, Brendan Eich <bren...@mozilla.com> wrote: > On May 18, 2009, at 11:53 AM, Neil Mix wrote: > >>> But for this to be true, we would need to use the direct-eval detection >>> hack I mentioned previously. >> >> On the plus side, this would allow for feature detection of generator >> support, right? (Is there any other way to detect generator support?) > > In JS1.7 you could object-detect: > > if (this.Iterator) ... > > or similarly. > > But I'm in the midst of writing up strawman:iterators proposal that doesn't > add Iterator to the global object (nor any __iterator__ getter, no double > underscores). > > One generalized idea for object detection of keywords that could be used as > if they named functions in code that would be work in old browsers: > > if (Object.implementation && Object.implementation.supports('yield'))) { > ... > function gen() { ... yield(E); .... } > ... > } else { > ... do something else ... > } > > I'm abusing Object as ES5 does, but harder, to avoid polluting the global > object. I'm supposing Object.implementation could be useful for other > properties than the supports method. This reads well enough, although its a > bit long-winded altogether (but individual names are short enough). > Comments? > > /be > _______________________________________________ > es-discuss mailing list > es-discuss@mozilla.org > https://mail.mozilla.org/listinfo/es-discuss > _______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss