[Top][All Lists]

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

Re: Closure?

From: Neil Jerram
Subject: Re: Closure?
Date: Sat, 12 Jul 2008 23:57:24 +0100

Hi Maciek,

Just picking up another point from your original email.  You may have
already worked this out, but just in case...

2008/7/11 Maciek Godek <address@hidden>:
> Additionaly, it would be nice to see the possibility
> of explicit definitions of environments, like:
> (define env (make-closure (a . 1)(b . 2))
> (with env (define c 3))

This is equivalent to:
(define env (let ((a 1) (b 2)) (the-environment)))
(local-eval '(define c 3) env)

except that the last line fails with a "Bad define placement" error.
That's because there are special rules for defines inside lexical

> so that we could define the aforementioned
> counter as:
> (define counter-env (make-closure (c . 0)))
> (define ++ (with counter-env (lambda()(set! c (1+ c))c)))

This one really works:

(define counter-env (let ((c 0)) (the-environment)))
(define (++) (local-eval '(begin (set! c (+ c 1)) c) counter-env))

So, in summary, make-closure wouldn't provide anything more than what
we already have.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]