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

docs and examples #7

Open
peter7891 opened this issue Jul 27, 2023 · 2 comments
Open

docs and examples #7

peter7891 opened this issue Jul 27, 2023 · 2 comments

Comments

@peter7891
Copy link

peter7891 commented Jul 27, 2023

Can you document the differences between the types Rooted and Handle?
They seem to be very similar. Maybe, also some examples of the 2 different usecases they satisfy.
I have a stack VM and when i allocate a new object, i do insert on the heap and it gives back a Rooted<T>.
But on the example, you are using Handle in the Object enum. Should i do rooted.into_handle()?
It is unclear.
It looks like, the Handle will not keep the object alive.

@zesterer
Copy link
Owner

Yes, you're correct. Rooted will survive a heap clean (and acts as the 'root' of an object tree) whereas Handle will not. If you have a stack VM, items on your stack should probably be Rooted<Value>s, but references within your Value should be Handle<Value>s.

@peter7891
Copy link
Author

peter7891 commented Aug 4, 2023

Yes, you're correct. Rooted will survive a heap clean (and acts as the 'root' of an object tree) whereas Handle will not. If you have a stack VM, items on your stack should probably be Rooted<Value>s, but references within your Value should be Handle<Value>s.

Right. Rooted is like Rc<T> and Handle is like Weak<T>

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

2 participants