This is the mail archive of the
guile@cygnus.com
mailing list for the Guile project.
Re: Weak observers (was Re: The taming of the before-gc-hook)
Mikael Djurfeldt <mdj@mdj-pc.nada.kth.se> writes:
Two clarifications:
> 1. Since the time for removal of elements isn't very critical I
> suggest that you use ordinary scheme lists. You could have one
> list for ordinary observers and one for weak ones. The obvious
> advantage is that accessors for such lists already exist.
With this solution, the TOKENs returned by scm_env_observe and
scm_env_weak_observe would be the functions themselves.
C functions would be put on a third list.
> 4. Execute the following code immediately after the sweep phase:
>
> ls = environment->weak_observers;
You'd need a way to find the environments. Look at the guardians.
Obviously you can modify my suggestion in order to support one kind of
observer objects if you'd prefer that.