0

Hash tables in elisp supports weak references, however weak references may be useful without the need to use a hash.

How can a weak reference to an object be defined without having to use a hash-table containing one item?

Drew
  • 75,699
  • 9
  • 109
  • 225
ideasman42
  • 8,375
  • 1
  • 28
  • 105
  • Submit a patch for such a data structure, wait some time, use it in the next Emacs release. Alternatively you can speed up the process with an Emacs module or fake it with hash tables: https://nullprogram.com/blog/2012/12/17/ – wasamasa Jan 29 '20 at 17:57

1 Answers1

1

General-purpose weak references would indeed be a useful general-purpose feature for elisp.

It's worth mentioning that in lieu of that functionality, there's a mini convenience library for exactly the strategy you mention (using a hash table with weak values and a single constant as a key) to obtain an effective weak reference: elisp-weak-ref.

ebpa
  • 7,319
  • 26
  • 53