This package provides two functions:
weak-ref
: Creates a weak reference to an objectweak-ref-deref
: Access the object behind a weak reference
See it in action:
(setq ref (weak-ref (list 1 2 3)))
(weak-ref-deref ref) ; => (1 2 3)
(garbage-collect)
(weak-ref-deref ref) ; => nil
It's build on top of the weak references provided by hash tables.