munificent / craftinginterpreters

Repository for the book "Crafting Interpreters"
http://www.craftinginterpreters.com/
Other
8.5k stars 1.01k forks source link

Ch18 - peek() function needs forward declaration #1063

Open Sidewinder1138 opened 2 years ago

Sidewinder1138 commented 2 years ago

In Ch18, the book tells me to add the static Value peek(int distance) function "after pop()" in vm.c. Of course, peek() is called earlier in that file, so it won't compile without a forward declaration. I added one and things compile and run just fine, but it seemed odd that the book text didn't mention it (unless I missed it somehow).

Sidewinder1138 commented 2 years ago

I also had to forward declare isFalsey: static bool isFalsey(Value value);

Sidewinder1138 commented 2 years ago

In Chapter 21, I found I needed to forward declare identifierConstant() in compiler.c as well.

mcfriend99 commented 2 years ago

You must have mixed things up somewhere. If you followed the placement guides strictly, none of those functions need a forward declare.

Sidewinder1138 commented 2 years ago

@mcfriend99 Ok, I just wanted to be sure it was my mistake, thx.