Mojo implementation question regarding borrow checker
Hello,
I am a student learning about Programming Language Theory and I have a question regarding Mojo's implementation of Borrow Checking.
In Rust, borrow-checking is performed by statically analysing the types of variables at compile time. However in Mojo, there doesn't seem to be a type for references, and there also doesn't seem to be any syntax for dereferences.
So my question is, how does Mojo perform its borrow checking? Does it automatically add a reference within the scope of the function? What if one needs to dereference?
I understand that Mojo's compiler is currently closed source, but if anyone could point me towards any relevant papers, or give any detail on its implementation in contrast to Rust's implementation I would be very grateful.
Thanks
3 Replies
In terms of References, they have seemed to have been a top priority for a while. They are in the language now fully but still in their early stages, let me know if that helped. https://docs.modular.com/mojo/stdlib/memory/unsafe.html#reference
unsafe | Modular Docs
Implements classes for working with unsafe pointers.
@jorge To directly answer your question: Mojo's borrowing system is unfinished, and there's not much you can study right now. I would check back in 3-6 months.
The current implementation of the
Reference
type is just a WIP and is subject to change.@benny @Nick! Thanks for getting back to me guys, ill be sure to check back later!