naringas / craftinginterpreters-plox

Lox from Crafting Interpreters but in Python
0 stars 0 forks source link

closure scoping bug present #4

Open ysangkok opened 1 year ago

ysangkok commented 1 year ago
 % python plox/plox.py ../crafting-interpreters/closure-bind.lox
readin ../crafting-interpreters/closure-bind.lox
global
block
 % cat ../crafting-interpreters/closure-bind.lox 
var a = "global";
{
  fun showA() {
    print a;
  }

  showA();
  var a = "block";
  showA();
}

The error from resolving and binding seems to be present. You probably know, but now you know i know :P

naringas commented 1 year ago

I think maybe I would rather re-define the language so to be able to argue that this is not a bug; that my own "plox is not lox" language is intended to work like this.

fixing this is just a matter of implementing the resolver and following the book, my proposed reaction "this is not a bug because plox is not lox" seems more interesting; potentially more illuminating

ysangkok commented 1 year ago

ok good to know! but with every deviation it becomes harder to compare... not sure how to keep track of the differences