[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
data structures <--> functions
Date: Sun, 6 Dec 87 01:51:10 est
From: gjs at ZOHAR.AI.MIT.EDU (Gerald Jay Sussman)
To: JAR at AI.AI.MIT.EDU
Re: data structures <--> functions
I really feel the need for EVAL (or ENCLOSE) quite seriously.
In particular I find the need to execute code that my programs write.
I wish this would be somehow solved.
How about if we put a meta-circular evaluator into the scheme library
that only knows about the standard R^3RS global variables? Then if you
wanted to evaluate (+ (EXPT 2 23) 7), you could do
(LOAD "scheme-library/eval") ;or whatever
(EVAL-IN-R^3RS-ENV '(+ (EXPT 2 23) 7))
Then, although particular implementations could choose to do "efficient"
implementations of this library routine, the beast is implementable in
R^3 Scheme, so no one could complain about its semantics or any
threat to change the language definition itself.
The only problem is, what if the expression E has free variables (e.g.
FOO) that are defined in the current environment, but not in the R^3RS
global environment? Well, if FOO isn't going to be assigned, how about
((EVAL-IN-R^3RS-ENV '(LAMBDA (FOO ...) E))
FOO
...)
or, if it is going to be assigned, something more complicated, like
((EVAL-IN-R^3RS-ENV '(LAMBDA (GET-FOO SET-FOO! ...) E'))
(LAMBDA () FOO)
(LAMBDA (VAL) (SET! FOO VAL))
...)
where E' = E with (GET-FOO) substituted for FOO and SET-FOO! substituted
for SET! FOO. Or, another entry point to the interpreter could be created
that would do substitutions of this kind automagically.
I think this would serve moderately well.
I'd be happy to submit such a package to the library (name and arguments
negotiable) if there's interest. This could at least hold us until we
can come to agreement over something that would give real level-crossing
access to environments.