[HN Gopher] Ephemerons explained
       ___________________________________________________________________
        
       Ephemerons explained
        
       Author : kencausey
       Score  : 14 points
       Date   : 2022-06-08 14:13 UTC (1 days ago)
        
 (HTM) web link (lists.squeakfoundation.org)
 (TXT) w3m dump (lists.squeakfoundation.org)
        
       | stevedekorte wrote:
       | Neat idea. Would moving the dependents list to an instance
       | variable holding a weak array avoid the need for ephemerons here?
        
         | ghusbands wrote:
         | Where would the weak array be stored? Ephemerons are often used
         | when you can't attach data directly to either the key object or
         | the value object. It's the simplest efficient primitive that
         | lets you encode "if object A is reachable, object B also is"
         | without otherwise affecting the visibility of A (or B),
         | altering A, or needing multiple GC cycles to settle.
        
           | stevedekorte wrote:
           | On the instance. My understanding is that in this example,
           | the instance itself is the key and is only stored in a
           | dictionary owned by the related class. Maybe there are other
           | or broader use cases, but for this particular case, storing
           | dependents on the instance seems to (AFAICS) solve the
           | problem without adding complexity.
        
       | Diggsey wrote:
       | AKA, a single entry in a WeakKeyDictionary
        
         | ghusbands wrote:
         | Well, WeakMap implementations (like WeakKeyDictionary) that
         | don't delay GC significantly do indeed use ephemerons.
        
       | kwatsonafter wrote:
       | I clicked on this thinking it would be about philosophy but I was
       | delighted to be once again thrust into Squeakland. God bless you
       | Dan Ingalls!
        
       ___________________________________________________________________
       (page generated 2022-06-09 23:00 UTC)