kanaka / mal

mal - Make a Lisp
Other
10k stars 2.53k forks source link

lexicial versus dynamic #645

Closed albertvanderhorst closed 1 week ago

albertvanderhorst commented 1 year ago

The most straightforward and important test is missing for environments: the test whether environments are truely lexical


(def! a 12)
(def! fx (fn* () a)
(fx)
(def! a 2000)
(fx) 

My implementation gave 12, 2000 of (fx) and apparently this should be 12,12 . So I have heard, but I could be mistaken. The more reason to put this test in.

kanaka commented 1 week ago

@albertvanderhorst That's a good test. The first call to fx should be 12, the second 2000 (because function creation should bind the current environment and def! I created a PR that includes another env binding test here: https://github.com/kanaka/mal/pull/677 so I'm going to close this issue now.