Idorobots / spartan

A small Lisp dialect that serves me as a test bed for programming language features.
MIT License
14 stars 3 forks source link

A way to preserve free-vars and related annotations between different passes of the compiler. #141

Open Idorobots opened 3 years ago

Idorobots commented 3 years ago

Currently the annotate-free-vars pass adds free variable metadata to the AST, but that information is gradually lost when the other passes run. It's inconvenient to always maintain these (for instance reorder-letrec-bindings) but it is really inconvenient that these are not preserved. It's also slow to recompute on each AST change. Perhaps keeping these annotations in sync could be extracted into a generic AST walker and intertwined with the other passes?

I.e.

(walk-ast (with-free-vars
           (lambda (expr)
             ...
             ))
          expr)

...ensures that output of the pass maintains all the free vars correctly.