eval in procedure environment

From: Olaf Gellert <1gellert_at_informatik.uni-hamburg.de>
Date: Mon, 10 Mar 1997 18:48:45 +0100 (MET)


I'm trying to execute a function (eg. defined in the global environment)
in the environment of a second function, so that it has access to
the data of the second function. Example:

>(define function2
            (let ((data 1))
            (lambda () data)))
>(eval 'data (procedure-environment function2))

Alright, that works. But if I try this with a procedure, it doesn't:

>(define function1 (lambda () data)
>(eval '(function1) (procedure-environment function2))

        *** Error:
            unbound variable: data
        Current eval stack:
          0 data
          1 (eval (quote (function1)) (procedure-environment function2))

Where is my mistake? What happens, if eval calls function1?

Thanx for any help!

Olaf Gellert
  gellert_at_informatik.uni-hamburg.de _ - __o
    Universitaet Hamburg, FB Informatik _- _`\<,_
      www.geocities.com/TheTropics/1263 - (_)/ (_)
Lieber Gott, ich frage Dich: | Kannst Du mir die Gruende nennen?
Warum bitte lerne ich | Kann denn nicht der ganze Haufen
immer doofe Frauen kennen? | in 'ne andere Richtung laufen?
Received on Mon Mar 10 1997 - 18:48:54 CET

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST