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

Add a real implementation of SRFI 124 based on Gambit's wills #611

Merged
merged 2 commits into from
May 11, 2021

Conversation

dpk
Copy link
Contributor

@dpk dpk commented May 8, 2021

The implementation behaves a bit weirdly — if you inspect the ephemeron-key in the REPL, the ephemeron won’t be broken until the datum also has no references anywhere else. I assume this is something to do with Gambit’s GC/REPL/object table/whatever, and I’m not about to start poking around in there. But in essence, it works:

> (define a (list 1 2 3))
> (define b (cons 4 5))
> (define e (make-ephemeron a b))
> (set! a #f)
> (##gc)
> (ephemeron-broken? e)
#t
> (ephemeron-key e)
#f
> (ephemeron-datum e)
#f

I’m also not quite certain this is a correct implementation of reference-barrier. Afaict even in a full implementation it’s just a void procedure meant to keep a certain value on the stack and therefore accessible?

(Also, like in Chibi, the ephemeron will never be broken if the datum refers to the key. This can’t be fixed without changes in Gambit, I think.)

@dpk
Copy link
Contributor Author

dpk commented May 8, 2021

Wait. Hold off on merging this for now — I think I’ve worked out how to get it to collect ephemerons with a cycle from datum to key, but I don’t have time to try it out right now.

@dpk
Copy link
Contributor Author

dpk commented May 8, 2021

Okay, that’s a bit of a hack, but it works. The weirdness with the REPL persists, but if you want to inspect an ephemeron’s contents, you can use an explicit call to write and it’ll break the ephemeron as usual later. Now mergeable if you can confirm that my intuition about reference-barrier is correct.

Copy link
Collaborator

@vyzo vyzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM modulo one minor comment.

I honestly don't know what to do about the reference-barrier either, void seems fine.

Copy link
Collaborator

@vyzo vyzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!

@vyzo vyzo merged commit 3281ee7 into mighty-gerbils:master May 11, 2021
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

Successfully merging this pull request may close these issues.

2 participants