Lines: 48
Newsgroups: comp.lang.scheme
Message-ID: <4dfmsq$q3i@news00.btx.dtag.de>
From: menszner@t-online.de (Dieter Menszner)
Path: cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!newsfeed.pitt.edu!gatech!news.mathworks.com!fu-berlin.de!news.belwue.de!news.uni-stuttgart.de!news.ruhr-uni-bochum.de!news.rwth-aachen.de!genesis.westend.com!news2.gtn.com!gtnduss1.du.gtn.com!ius.gun.de!roka.net!news.space.net!news.ecrc.de!news00.btx.dtag.de!not-for-mail!menszner
Subject: Re: silly newbie question about evaluation-contexts.
Date: Tue, 16 Jan 1996 07:16:26 +0000
References: <4d16qa$klt@gutemine.informatik.uni-kiel.de>
X-Gateway: ZCONNECT XX ius.gun.de [UNIX/Connect v0.73]
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Z-STICHWORT: bs
X-Z-STICHWORT: cs
X-Z-STICHWORT: eval
X-Z-STICHWORT: environments
X-Z-STICHWORT: bindings
X-Z-STICHWORT: closures

hukriede@xerxes.ifm.uni-kiel.de wrote:

> Hi schemers !
>
> Could you take a kind look at the following:
>
>     guile> (define x 999)
>     guile> (define foo '(lambda (a) (list a x)))
>     guile> (let ((x 1000)) ((eval foo) 1))
>     (1 999)
>
>
>     elk>   (define x 999)
>     elk>   (define foo '(lambda (a) (list a x)))
>     elk>   (let ((x 1000)) ((eval foo) 1))
>     (1 1000)
>
>
> Oops.. what's going on here ?? Might be
>
>     (1)    guile broken ?
>     (2)    elk broken ?
>     (3)    scheme underspecified ?
>
> I would vote for 1 and 3, any opinions, comments ?
>
A function like (eval foo) is not in the scheme specification so (3) is
not applicable.
The difference in the answers of elk and guile could result from different
definitions of 'eval'. eval needs an environment to operate. elk and
scheme may use different ones.

My guess:
Guile's eval uses the global environment. Then the lambda expression would
be evaluated in this env.
And the answer (1 999) of guile is correct by scheme's lexical scoping  
rule.

Elk's eval might use the current environment. Here x is bound to 1000
because of the let. With this convention the answer of elk is also
correct.


   Dieter Menszner

            *** This line intentionally left blank. ***


