using Private name objects for declarative property definition.

Sam Tobin-Hochstadt samth at
Sat Jul 9 05:42:15 PDT 2011

On Sat, Jul 9, 2011 at 3:48 AM, Andreas Rossberg <rossberg at> wrote:
>> We went back and forth on this. I believe the rationale is in the wiki (but
>> perhaps in one of the strawman:*name* pages). There are a couple of reasons:
>> 1. We want private name objects to be usable as keys in WeakMaps. Clearly we
>> could extend WeakMaps to have either "object" (but not "null") or "name"
>> typeof-type keys, but that complexity is not warranted yet.
> I can see that being a relevant use case for weak maps. But the same
> logic applies to using, say, strings or numbers as keys. So isn't the
> right fix rather to allow weak maps to be keyed on any JS value?

Unlike Names, strings and numbers are forgeable, so if they were
allowed as keys in WeakMaps, the associated value could never be
safely collected.  Names, by contrast, have identity.
sam th
samth at

More information about the es-discuss mailing list