WeakMap API questions?

Sam Tobin-Hochstadt samth at ccs.neu.edu
Tue Sep 7 09:41:15 PDT 2010

On Thu, Sep 2, 2010 at 12:47 PM, Mark S. Miller <erights at google.com> wrote:
> In the names proposal, it seems that once in scope of a "private draw"
> declaration, all apparent uses of "draw" as a property name are amplifying.
> Even if the object being accessed has a normally named "draw" property,
> "gun.draw()" will fail to access it. Is that right?

Yes, that's correct.  In the scope of a 'private x' declaration, all
uses of F.x are rewritten to F[x] instead of the usual F["x"].  If you
want F["x"], it can be written explicitly, of course.

It's important to have this property so that names can be used to add
non-interfering additional properties to existing objects.  In
particular, a rendering library should be able to add 'draw' methods
to cowboys without interfering with any of their existing properties.

Also, I really don't think that rewriting f.x to f[x] is amplifying,
since that expression is necessarily already able to access the
private name, since it is in scope.
sam th
samth at ccs.neu.edu

More information about the es-discuss mailing list