Open SpecificProtagonist opened 1 year ago
I don't think I am going to fix this honestly, it sounds too much work and I consider the project "finished" (in the sense that I learnt what I had in mind initially and I want to move on to other things).
In any case, solution 1 is pretty clear to me.
I am a bit uncertain on solution 2: what do you mean with erase lifetimes internally? Can you point out to any example or just sketch a few lines of code?
Thanks a lot!
Here's an example. I don't currently do the Arc
thing though; the project is pretty unfinished (so don't judge it too harshly :3).
Happy to help ^^
VM
has a lifetime'a
. This lifetime is arbitrary – it is chosen by the caller with no restrictions. This means it can outlive theVM
, but other structs assume theVM
is life for'a
. This is unsound.Segfaulting example:
Possible solutions:
VM
. All methods that produce lifetimed objects take their lifetime from the reference to theVM
.VM
. Keep VM in anArc
. Erase lifetimes internally. Don't hand out structs referencing VM memory directly, instead hand out a wrapper object that also contains a copy of theArc
(this can be transparent to the user).