Hacker News new | past | comments | ask | show | jobs | submit login

How is an interpreter expressed in Rust- what parts can be safe and what must be unsafe? For example the GC conceptually has access to every object at every allocation point, how does that work with the borrow checker?



Depends on the details. If you are just doing a classic AST interpreter, no particular focus on speed, there's no need for unsafe code at all, especially if you do what Python does and just use refcounting, though I have not implemented a cycle detector personally...


Reference counting and/or memory arenas and/or selective use of unsafe { }, depending on your goals

This post provided a great deep-dive anecdote on just that: https://news.ycombinator.com/item?id=28026562




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: