3 ms·
Any trouble with the Rust implementation? I wanted to give the book a go using Rust, but have been sitting on it because I don't want to get halfway through it
by heavyset_go 4y ago
Any trouble with the Rust implementation? I wanted to give the book a go using Rust, but have been sitting on it because I don't want to get halfway through it only to find that Rust's intentional design and limitations might make it difficult to build an interpreter via the assumptions in the book.
- dento 4y agoI've been loosely following the book with Rust, and no issues so far. Both the compiler and interpreter are implementable without much issues. You'll have to adapt a bit, but in general you can use the same methods.
- jeffdn 4y agoYou can do it pretty much verbatim, with dynamic dispatch using enums and lots of pattern matching. It gets a bit trickier when you are nesting environments for closures and the like, but certainly nothing insurmountable without a few things from the standard library.
- bow_ 4y agoNot really (for the first part at least, am not yet finished with the second part). I did deviate a little bit with my Rust implementation. This was my goal anyway: implement Lox differently. Off the top of my head: * I used ADTs to encapsulate error types and states as much as possible, this lead to heavy use of enums and pattern matching. * I implemented the `Environment` as an immutable, explicitly passed value. This was a little challenging at first, but overall quite satisfying to do.