[ prog / sol / mona ]

prog


Ephemerons

1 2020-08-13 06:07

An ephemeron is an object with two components called its key and its datum. It differs from an ordinary pair as follows: if the garbage collector (GC) can prove that there are no references to the key except from the ephemeron itself and possibly from the datum, then it is free to break the ephemeron, dropping its reference to both key and datum. In other words, an ephemeron can be broken when nobody else cares about its key. Ephemerons can be used to construct weak vectors or lists and (possibly in combination with finalizers) weak hash tables.

http://mumble.net/~campbell/tmp/ephemeron.txt
https://srfi.schemers.org/srfi-124/srfi-124.html

2 2020-08-13 09:49

This is interesting, won't work well for compiled scheme though. I like the ephemeron-broken idiom.

3


VIP:

do not edit these