Eval introduces an interesting problem because it allows introspection, e.g.
(define (foo x) (* x x)) ;; foo is not called directly by the program
(pretty-print ((eval 'foo) 10)) ;; should print 100
So if the code can call eval, then anything accessible from the toplevel must be retained in the executable. If after tree-shaking the code contains a call to eval, then nothing can be thrown away. That's the price to pay for an introspective system. Note that many things might call eval, such as the REPL, or the exception handling system and even "read", so in practice it may be hard to remove much code. One "solution" is to add some switches to the compiler to ask it to not support the REPL, and to exit abruptly when an exception is raised.
Marc
On 3-Oct-08, at 5:38 PM, Mikael More wrote:
In case you would implement this, how would eval work?
Mikael