brh@hare.udev.cdc.com (brian r hanson x6062) (02/22/91)
How does one in scheme find the value of an expression contained in a list? In common lisp this is done with "eval" but I have not found any equivalent interface in scheme. Brian Hanson
mkatz@garlic.stanford.EDU (Morris Katz) (02/23/91)
Date: 21 Feb 91 16:15:44 GMT From: brian r hanson x6062 <brh@hare.udev.cdc.com> How does one in scheme find the value of an expression contained in a list? In common lisp this is done with "eval" but I have not found any equivalent interface in scheme. A conscious decision was made not to include EVAL in standard scheme. There were two primary problems that I remember people having with eval: 1) Analysis of programs which contain eval is more difficult. Some people's program development tools could not perform the same types of functions in a language which includes eval. 2) There is a question as to what environment the argument to eval should be evaluated in. Those who have extended scheme to include first-class environments often solve this problem by explicitly supplying eval with a second argument which is the environment in which evaluation should be performed. Others argue over whether the environment for evaluation should be the current execution environment from which eval is called, the top level environment, or some other environment. Despite the lack of a standard eval in Scheme most every implementation of which I am aware has an eval function. The only problem with using it is that you don't get portable code. In those implementations in which eval is not present, you can create a poor mans eval using file-i/o and LOAD. (i.e., You can write the piece of code to be executed out to a file and then load it.) There are two problems with this approach: 1) The environment in which load excutes is not to my knowledge specified in R4RS. 2) The return value of LOAD is unspecified so values can only be returned via side effects. -------------------- Morry Katz katz@cs.stanford.edu --------------------