munificent / craftinginterpreters

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

Statements and State #122

Closed colms closed 7 years ago

colms commented 7 years ago

Some stuff that might be worth throwing an eye over:

var x, y = 0;

or

var x = y = 0;

right?

munificent commented 7 years ago

" A print token" => "A PRINT token". I'm not sure on the style guide on whether token that appear in text should remain capitalized.

I think it's a little clearer to use the literal text of the token (print) instead of the enum that corresponds to it, so sticking with that.

"in microcosm" => "in a microcosm"

This reads a little funny, but it's deliberate. I'm using "microcosm" as an... adverb? not a noun. In the same vein as "in reverse" or "in miniature".

In the block after "we add a new statement tree for a variable declaration", should the Print line also be highlighted? It probably should but I just want to be sure.

It should, yes, though this trips up a lot of readers. If you notice the slugline on the right, it says "replace one line". In the previous version of the code there, there was no comma at the end of the print line, so it's telling you to add that now.

isEven()‘s - this is a nitpick but the direction of that apostrophe seems off.

You are correct! I put a surprising amount of effort into automating getting the punctuation right, but the script that handles it gets tripped up on apostrophes following inline code. :-/

just to be sure, this means Lox can do: var x = 0; var y = 0;

Yes.

but not:

var x, y = 0;

Right.

var x = y = 0; right?

You can do this. It's initializing x with the result of the assignment expression y = 0.

"or the less common static scope" => "less commonly known as static scope". I think that's what you mean?

I think the quotes technically make the use-mention distinction technically unambiguous, but you're right it's unclear. Fixed.

I don't like the use of a for loop in the sumToTen function.

Yeah. I think using functions is the even more confusing part here since functions directly muck with scope themselves. Used a different example.

Did all the other things you suggested. As always, thank you!