Is there a way to pin a variable in Dyon memory?
For the interop lib I'm making right now, sometimes I want to effectively pass a mutable reference to Dyon from Rust. This is a bit more ergonomic than having to have the scripter call a return_this_object_to_rust_memory_now_thanks(obj). Of course, this isn't possible, because Dyon formats its memory differently, so I've resorted to storing the memory in the Dyon stack, and then sending Dyon a pointer to its own memory when it asks for these variables. If the variable they're asking for doesn't already exist, I allocate it newly, if it does I return a pointer to the index in the stack I've recorded. This would work perfectly, if Dyon didn't keep dropping the memory I'm trying to manage manually from Rust. Is there a way to pin a variable in Dyon memory? I considered just asking for a way to do what I'm doing specifically but I feel like a pin could have other uses as well. Thanks for your time!
Not sure if I understand this use case correctly, but it sounds like something I would write an abstraction over by handling all unsafe aspects and code that needs to be optimized on the Rust side.
Have you looked at the current library? Is this something you are looking for?
I'm actually already using Current, it's made writing my Rust/Dyon interop code really easy (if a bit unsafe D:) Unfortunately it doesn't cover this usecase.
There is already an Variable::UnsafeRef variant that is used behind the scenes, e.g.:
a := [1, 2, 3]
// `a[2]` is resolved, after value on right side is evaluated,
// and pushed as an unsafe reference to stack,
// before executing the assignment operator.
a[2] = 4
https://github.com/PistonDevelopers/dyon/blob/master/src/lib.rs#L170
The runtime abstracts over this safely. However, the same variant might be used to support pointers to Dyon variables.
Is this closer to your use case?