[Top][All Lists]

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

Re: Req for help on objects and environments

From: Andy Wingo
Subject: Re: Req for help on objects and environments
Date: Wed, 22 Sep 2004 19:07:24 +0200

Hey Marius,

On Tue, 2004-09-21 at 22:47 +0200, Marius Vollmer wrote:
> It is best not to fiddle with the implementation of lexical
> environments (expect when you are writing a debugger, say).  Something
> like the following might be sufficient and is cleaner.
>     (define-macro (with-env env . body)
>       (let ((module (current-module)))
>         `(let ((code (cons* 'let ,env ',body)))
>            (eval code ',module))))
>     (define env (make-environment 'a 12 'b 13))
>     (pk (with-env env (+ a b)))

Yeah, I think I would have done this if I hadn't needed to keep state in
the environment. I agree it's ugly though -- it would be impossible to
compile this code, for instance, because it violates the
implementation's prerogative to implement environments as they like. I
should probably implement my stuff with anonymous modules.

Andy Wingo <address@hidden>

reply via email to

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