munificent / craftinginterpreters

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

"Chunks of Bytecode" challenge recommends storing long constants' indices as 24 bit, but "Compiling Expressions" aside recommends using 16 bits #997

Open AaronRecord opened 3 years ago

AaronRecord commented 3 years ago

See https://craftinginterpreters.com/compiling-expressions.html#parsers-for-tokens (Note) And https://craftinginterpreters.com/chunks-of-bytecode.html#challenges (Challenge 2)

Not a big deal, but it's a little confusing. Should there be OP_CONSTANT_8, OP_CONSTANT_16, and OP_CONSTANT_24 instructions? I know it probably depends largely on the language, but it might be nice to know what the most common way of doing this is in popular language implementations.

image

image