Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(srfi 124) implements weak pairs, not ephemerons #807

Open
dpk opened this issue Dec 17, 2022 · 0 comments
Open

(srfi 124) implements weak pairs, not ephemerons #807

dpk opened this issue Dec 17, 2022 · 0 comments

Comments

@dpk
Copy link

dpk commented Dec 17, 2022

Ephemerons should be broken if the only remaining strong reference to their key is inside their datum:

> (import (srfi 124))
> (define x (list 'x))
> (define ex (make-ephemeron x x))
> (set! x #f)
> (##gc)
> (ephemeron-broken? ex)
#f ;; expected: #t
Compare Racket-Chez 9.5.9.9 (for Racket 8.7)
> (define x (list 'x))
> (define ex (ephemeron-cons x x))
> (set! x #f)
> (collect)
> ex
(#!bwp . #!bwp)

I attempted to fix this in Gerbil using a pair of wills, but as Andy Wingo discovered, this is wrong too.

I think true ephemerons cannot be expressed in terms of wills.

The best fix would be to change Gambit’s primitive weak-referencing system to ephemerons with finalizers (as in Haskell and XEmacs) instead of weak boxes with finalizers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant