[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

eval and orbit



    My program is supposed to read values of enumerated types (i.e.
    symbols) and then convert the symbols to their values.  In regular
    Lisp I would write (eval (read)) to get the value but how am I
    supposed to do that in Scheme?  Use a mapping function from names to
    values or is there a simpler way?

Besides the fact that EVAL is not really necessary for most
programming, the problem is that we could not agree on what eval would
mean or do (we didn't try very hard because of the other reason):

Some implementations have a single global environment where
expressions could be evaluated.  In these implementations (eval <x>)
would make sense.

Other implementations have multiple environments where code can be
evaluated.  In these implementations (eval <x>) does not make much
sense.  Eval needs to take a second argument specifying what
environment to evaluate in, and it is not clear that a reasonable
default can be provided so that 1 argument EVAL could work.

You should use a mapping function or something like it if you want
your code to be portable.  Most implementations have an EVAL procedure
(with different behavior) which you can use if you don't care about
that.