On Apr 19, 2014, at 9:37 PM, Bradley Lucier lucier@math.purdue.edu wrote:
Marc:
It's not quite clear to me what object->u8vector does with procedures.
I was thinking that if it pulled in all the functions not in system libraries, then it could be used as a tree-shaker.
This is only a vague thought, but I find its interesting.
Brad
Interpreted and compiled procedures are serialized differently. The interpreter is rather lazy and procedures will close over all of the lexical environment at the site of the lambda. The interpreter is smarter and will close over the non-global free variables. Note that in both cases the global environment is never closed over. In the following code:
(define (f x) (g (+ x 1)))
(define (g x) (* x x))
two procedures are created, one bound to f and the other to g. The procedure bound to f will not contain a reference to the procedure bound to g. The procedure bound to f will only refer to the global variable g, and this global variable will be dereferenced when the body of f is executed.
So serializing the procedure bound to f will not magically collect all of the code that is needed to run f. In fact, if the deserialization happens in a context where g is not bound, calling the deserialized procedure will give an “unbound variable g” error.
Marc