gluon-lang / gluon

A static, type inferred and embeddable language written in Rust.
https://gluon-lang.org
MIT License
3.16k stars 145 forks source link

Can Function::call borrow self immutably? #771

Open lePerdu opened 4 years ago

lePerdu commented 4 years ago

Is there a reason that vm::api::Function::call (and call_async and call_fast_async) take a mutable reference to self? The code compiles fine if they take immutable references.

Marwes commented 4 years ago

I had some plans that Function could instead hold the Mutex lock that protects the vm execution which would then require &mut. This would let the function be called multiple times withot reqaquiring the lock on every call. Never got around to it so atm it doesn't do anything.

You should still be able Clone the Function values though to share them and call them from multiple places. Not sure yet if I should fall back to making them &.