Questions tagged [crafting-interpreters]
6 questions
1
vote
2 answers
How do I make iterating over a vector on a struct via self mutable and use that mutable reference later?
I'm trying to iterate over a vector of statements and match (or double match) the results from evaluating them. I think the root cause of my error is the immutable borrow from iterating: for stmt in &self.statements
I'm totally fine changing my…

Josh R
- 1,970
- 3
- 27
- 45
0
votes
1 answer
persistent constant values - Crafting Interpreters
I am reading the "Crafting Interpreters" by Bob Nystrom on chapter 26 Garbage Collection. On the first page, he says with the following example:
var a = "first value";
a = "updated";
// GC here.
print a;
Say we run the GC after the assignment has…

Bhavya Bhatt
- 37
- 4
0
votes
0 answers
Compile-time storage of function objects for multiple-pass compilers
I am reading the famous book Crafting Interpreters by Bob Nystrom and I am on chapter-24 Calls and Functions. He builds a single-pass compiler in which functions need to be declared before usage so having function objects holding the same status as…

Bhavya Bhatt
- 37
- 4
0
votes
1 answer
How compile time local array index is same as runtime time stack index
I am reading from Book Crafting Interpreters by Bob Nystrom. I am on chapter 22-Local Variable in which under the section Using Locals he said
"At runtime, we load and store locals using the stack slot index, so that’s what the compiler needs to…

Bhavya Bhatt
- 37
- 4
0
votes
1 answer
Why the compiler is generating errors which aren't errors at all
I was trying to write my own VM implementation in C++ from the excellent book Crafting Interpreters.
The book builds a stack based virtual machine, of which I am writing a C++ version
So here is the code where the compiler is yelling at…

akm
- 338
- 2
- 11
0
votes
1 answer
Mimicking CraftingInterpeter's BINARY_OP macro
Came across this while trying to follow the excellent Crafting Interpreters book but using Rust instead of C.
The book builds a stack based virtual machine, of which I have a simple Rust version that looks something like:
struct VM {
stack:…

Increasingly Idiotic
- 5,700
- 5
- 35
- 73