On 13-06-18 10:06 AM, Matthieu Monrocq wrote:
Hi,
I was reading with interest the proposal on library-defined garbage
collection (by use of dedicated types), and I have a couple of questions.
My main worry, and thus question, is how to handle cross-scheme cycles ?
There does not seem to be anything preventing me to have a Rc<Object>
reference a Gc<Object> (and vice-versa), and I am wondering how garbage
collectors are supposed to cooperate to realize that those may be dead
cycles to collect.
There are 3 options that I'm aware of:
- Teach the GC to traverse foreign graphs, like the XPCOM CC does
- Statically prohibit such constructs
- Leak cycles and put a warning up
I don't have a strong preference. Maybe a minor preference for
statically preventing it (eg. a NonManaged bound, such as Daniel was
suggesting we add to help support the Rc<> type yesterday).
As such, I am wondering if despite being neat (and highly tunable) users
might not be satisfied with a simpler scheme. It seems to me that
lifetime already provide natural GC boundaries (they at least provide an
upper-bound of the lifetime of the object) and thus that maybe it may be
more natural to attach a gc to a lifetime (or set of lifetimes) rather
than to a particular object ?
I don't really know how this would work out. There might be something in
there that would work, but it'd require some more-detailed proposal. I
can't quite see it myself.
-Graydon
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev