[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Closure?
From: |
Maciek Godek |
Subject: |
Re: Closure? |
Date: |
Fri, 11 Jul 2008 22:54:35 +0200 |
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-display "env" (the-environment))
> (lambda()
> (set! c (1+ c)) c)))
I don't actually get the line with c-display.
Does it require any additional module?
'Cause it ain' workin' for me.
(and besides what does it do?
the remaining part works fine)
> (++)
> => 1
> (with (procedure-environment ++) (set! c 20))
>
> (++)
> => 20
I'm really impressed :) Great respect!
I only wonder if there's a way to add a new
variable to an existing closure, or to delete one.
(not that I need it right now; but I imagine that
it can be implemented quite easily and efficiently
in C if the notion of closure is well-defined and
explicit)
- Re: Closure?, Kjetil S. Matheussen, 2008/07/11
- Re: Closure?, Neil Jerram, 2008/07/12
- Re: Closure?, Ludovic Courtès, 2008/07/15
- Re: Closure?, Andy Wingo, 2008/07/16
- Re: Closure?, Ludovic Courtès, 2008/07/16
Re: Closure?, Kjetil S. Matheussen, 2008/07/14
- Re: Closure?, Maciek Godek, 2008/07/14
- Message not available