Re: WeakMaps question ?

2011-11-12 Thread Russell Leggett
On Nov 11, 2011, at 6:55 PM, Allen Wirfs-Brock al...@wirfs-brock.com wrote: On Nov 11, 2011, at 3:39 PM, Oliver Hunt wrote: A weak map can only remove an entry if both the key and value have died, in many ES implementations a number of the primitives are not gc allocated and so can

Re: WeakMaps question ?

2011-11-12 Thread Mark S. Miller
On Fri, Nov 11, 2011 at 3:55 PM, Allen Wirfs-Brock al...@wirfs-brock.comwrote: [...] Yes, but this isn't just an implementation decision. The primitive values have existential identify (my term, philosophers may mean something else). All such values conceptually exist for all time,

Re: WeakMaps question ?

2011-11-12 Thread Allen Wirfs-Brock
On Nov 12, 2011, at 5:10 AM, Russell Leggett wrote: Regardless of the implementation of primitive values, couldn't we say that the semantics of a weak map ignore primitive keys and look only at the value. Primitive keys are exceptionally common for maps, and this would open up a lot of

Re: WeakMaps question ?

2011-11-12 Thread Brendan Eich
On Nov 12, 2011, at 9:19 AM, Allen Wirfs-Brock wrote: On Nov 12, 2011, at 5:10 AM, Russell Leggett wrote: Regardless of the implementation of primitive values, couldn't we say that the semantics of a weak map ignore primitive keys and look only at the value. Primitive keys are

Re: WeakMaps question ?

2011-11-12 Thread Mark S. Miller
On Sat, Nov 12, 2011 at 11:56 AM, Brendan Eich bren...@mozilla.com wrote: WeakRef != WeakMap, we keep running into confusion between the two. WeakRefs are useful for systems-builders. They should not be exposed to unprivileged code. Is there an object-capability security model that would

Re: WeakMaps question ?

2011-11-11 Thread Irakli Gozalishvili
I really need to know why WeakMaps don't accept primitives as keys, can anyone please reply ? Thanks! -- Irakli Gozalishvili Web: http://www.jeditoolkit.com/ Address: 29 Rue Saint-Georges, 75009 Paris, France (http://goo.gl/maps/3CHu) On Thursday, 2011-11-10 at 10:31 , Irakli Gozalishvili

Re: WeakMaps question ?

2011-11-11 Thread Eric Jacobs
Irakli Gozalishvili wrote: I really need to know why WeakMaps don't accept primitives as keys, can anyone please reply ? How would the GC know when to remove the entry from the map? Because a primitive is never (or always, if wrapped) eligible for garbage-collection, a WeakMap does not help

Re: WeakMaps question ?

2011-11-11 Thread Kris Kowal
On Fri, Nov 11, 2011 at 3:28 PM, Irakli Gozalishvili rfo...@gmail.com wrote: I really need to know why WeakMaps don't accept primitives as keys, can anyone please reply ? It’s because WeakMaps are intended to drop values if the key is garbage collected. A WeakMap guarantees that it will drop

Re: WeakMaps question ?

2011-11-11 Thread Oliver Hunt
A weak map can only remove an entry if both the key and value have died, in many ES implementations a number of the primitives are not gc allocated and so can never die, or are cached globally so have lifetime unrelated to any given program. The net effect of allowing such primitive values to

Re: WeakMaps question ?

2011-11-11 Thread Irakli Gozalishvili
I think what I need is a map with primitive keys and non-null object values, entries of which can be removed GC-ied if values are no longer referenced. If I understand Map / Set / WeakMap proposals non of them can be used to solve this issue or do I miss something ? Regards -- Irakli

Re: WeakMaps question ?

2011-11-11 Thread Allen Wirfs-Brock
On Nov 11, 2011, at 3:39 PM, Oliver Hunt wrote: A weak map can only remove an entry if both the key and value have died, in many ES implementations a number of the primitives are not gc allocated and so can never die, or are cached globally so have lifetime unrelated to any given program.