Closure?

2008-07-11 Thread Maciek Godek
Hi folks, I've been wondering if there's any way to recall (or get inside) an environment of a closure (= to directly access variables bound to a closure) And here's what I mean exactly: (define ++ (let ((c 0)) (lambda()(set! c (1+ c))c))) ; we now have a closure (procedure-environment ++) ;-> (

Re: Closure?

2008-07-11 Thread Ludovic Courtès
Hi, "Maciek Godek" <[EMAIL PROTECTED]> writes: > I've been wondering if there's any way to recall > (or get inside) an environment of a closure (= to > directly access variables bound to a closure) Yes, with `the-environment': guile> ((lambda (a b) (the-environment)) 2 3) (((a b) 2 3) #) B

Re: Closure?

2008-07-11 Thread Maciek Godek
2008/7/11 Ludovic Courtès <[EMAIL PROTECTED]>: > "Maciek Godek" <[EMAIL PROTECTED]> writes: > >> I've been wondering if there's any way to recall >> (or get inside) an environment of a closure (= to >> directly access variables bound to a closure) > > Yes, with `the-environment': > > guile> ((lam

Re: Closure?

2008-07-11 Thread Kjetil S. Matheussen
Ludovic Court?s: "Maciek Godek" <[EMAIL PROTECTED]> writes: I've been wondering if there's any way to recall (or get inside) an environment of a closure (= to directly access variables bound to a closure) Yes, with `the-environment': guile> ((lambda (a b) (the-environment)) 2 3) (((a b)

Re: Closure?

2008-07-11 Thread Kjetil S. Matheussen
On Fri, 11 Jul 2008, Kjetil S. Matheussen wrote: > > > Ludovic Court?s: > > "Maciek Godek" <[EMAIL PROTECTED]> writes: > > > >> I've been wondering if there's any way to recall > >> (or get inside) an environment of a closure (= to > >> directly access variables bound to a closure) > > > > Yes,

Re: Closure?

2008-07-11 Thread Maciek Godek
Kjetil S. Matheussen: > The function "local-eval" is probably what you want. > > I use local-eval a lot, it's one of the really really > nice features provided by Guile: > > > (define-macro (with env . code) > `(local-eval (quote (begin ,@code)) ,env)) > > > (define ++ > (let ((c 0)) >(c-dis