Must built-in prototypes also be valid instances? (Was: Why DataView.prototype object's [[Class]] is "Object"?)

Allen Wirfs-Brock allen at wirfs-brock.com
Tue Oct 2 11:01:20 PDT 2012


On Oct 2, 2012, at 10:18 AM, Kevin Smith wrote:

> 
> private @FooBrand;
> class Foo {
>    constructor() {
>         /* establish the internal Fooness of the instance */
>         this. at FooBrand = true;
>    }
> }
> Foo.isFoo = function (obj) {return !!obj. at FooBrand};
> 
> Using this strategy, will isFoo not fail, if the specified object came from a different global context (frame)?
> 
> Kevin
> 

Indeed it would, but why shouldn't it?  Foo in another  frame is a different class.  If you need to do cross-frame brand, that seems like an additional requirement would require additional mechanism.

Wouldn't a WeakMap branding scheme has similar issues. You would need to share via some means a common WeakMap among constructors in different frames.  Just like to make symbol based branding work for this requirement you would have to share a private symbol between frames.

Allen


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


More information about the es-discuss mailing list