munificent / craftinginterpreters

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

Ch 19 Use BINARY_OP(NUMBER_VAL, +) instead of expanded form #1142

Closed astrolemonade closed 9 months ago

astrolemonade commented 9 months ago

Hey! I noticed that in https://craftinginterpreters.com/strings.html#struct-inheritance the BINARY_OP(NUMBER_VAL, +); is expanded for numbers but it doesn't add anything different than the old version.

astrolemonade commented 9 months ago

image This is how it will look.

astrolemonade commented 9 months ago

I looked again and I think you wanted to avoid checking the operands types again.

 if (!IS_NUMBER(peek(0)) || !IS_NUMBER(peek(1))) {                          
   runtimeError("Operands must be numbers.");                               
   return INTERPRET_RUNTIME_ERROR;                                          
 }