Specy / rooc

A language for compiling formal mathematical models into static models which are transformed to be solved
https://rooc.specy.app
MIT License
4 stars 0 forks source link

Performance improvements #1

Open Specy opened 10 months ago

Specy commented 10 months ago

Currently, during the transformation, function calls and reading a parameter return an owned value of the primitive. This isn't the best as it means that every time a function is called or a parameter is read, there will be a clone. I'm not sure what a good way to solve this would be, but I'm pretty much thinking a sort of heap type could be added to the transformer context, and variables will then have a reference to an Rc or something similar, then adding another primitive (Primitive::Ref) that will be a reference to an owned primitive, or something to derive the reference (like an id) (the owned value will be in this heap type)

Specy commented 10 months ago

this would also introduce issues like "when to delete that reference", at that point we could introduce a lifetime model like a RAII, so when the current context frame is popped, the constants that were declared in it will be dropped, and the references to previous owned primitives will still be available as they are in other frames. In general, as the language was designed, it wouldn't be possible for a parent frame to hold references created in child frames, so this approach should work

Specy commented 8 months ago

Instead I could just use Rc + RefCell or use the Gc crate