[plt-scheme] free variable and late binding in Dromadery

From: David Herman (dherman at ccs.neu.edu)
Date: Sun May 18 11:24:00 EDT 2003

I don't know Dromadery, but I believe you're looking at a scoping 
issue. The two different interpretations would look like this in Scheme:

(let ((x 1))
   (let ((f (lambda (y) (+ x y))))
     (let ((x 2))
       (f 0))))

The above program evaluates to 1, because the "x" that is in scope for 
the definition of the "f" function is the first definition.

(define x 1)
(define (f y) (+ x y))
(define x 2)
(f 0)

This one evaluates to 2, because the "f" function is referring to the 
globally scoped "x" variable, whose value has been changed to 2 when 
you evaluate (f 0).

In Scheme, the "let" construct is used for lexical scoping. From your 
example, it looks like the Dromadery language uses it only for 
assignment and not for scoping, but I'm not familiar with the language.

Dave

On Sunday, May 18, 2003, at 04:34 AM, Pierre CHATEL wrote:

>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> It seems that Dromadery's variable/value association system is the 
> same that in DrSCheme:
>
> In Dromadery :
> let x = 1;;
> let f(y) = x+y;;
> let x = 2;;
> f(0);;
> --> 2
>
> In DrScheme:
> (define x 1)
> (define (f y) (+ x y))
> (define x 2)
> (f 0)
> --> 2
>
> And finally in Caml (camllight)
> let x = 1;;
> let f(y) = x+y;;
> let x = 2;;
> f(0);;
> --> 1 !!!!!!!!!
>
> Is Dromadery result a bug or a functionnality ? :))
>
> Pierre



Posted on the users mailing list.