[swift-evolution] Proposal: Give weak references the ability to	notify reference-holders when they transition to nil
    Chris Lattner 
    clattner at apple.com
       
    Sun Dec 13 21:46:06 CST 2015
    
    
  
> On Dec 13, 2015, at 6:24 PM, Michael Henson via swift-evolution <swift-evolution at swift.org> wrote:
> 
> The use-case for this comes first from proposals to have a weak-reference version of collection types. Implementing a notification signal of some sort to weak reference-holders when the reference becomes nil would make implementing those more straightforward.
+1.  This is very useful for various kinds of APIs, like a weak hashtable that wants to remove the keys when/if they get deallocated.
> SInce this is the germ of an idea, I'll avoid suggesting a syntax for the mechanism so the discussion focuses on whether or not this is useful enough as a feature to be implemented.
IMO, ideally, this would be more of a runtime API than a language feature.
-Chris
    
    
More information about the swift-evolution
mailing list