chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] basic Scheme question


From: Peter Bex
Subject: Re: [Chicken-users] basic Scheme question
Date: Fri, 24 Oct 2008 08:44:06 +0200
User-agent: Mutt/1.4.2.3i

On Thu, Oct 23, 2008 at 10:27:18PM -0700, Shawn Rutledge wrote:
> #;10> (begin (define update #f) (let ([v 'foo]) (set! update (lambda
> (d s) (printf "~s was ~s~%" d (eval d)) (set! d s)))))
> #;11> (update 'v 'bar)
> Error: unbound variable: v
> 
> What I'm trying to do is pass the name of a let-bound variable in to a
> lambda defined within the let context, in order to tell that lambda to
> access that let-bound variable.  eval doesn't work because it looks in
> the outer environment, right?  (in which v is not bound)

Eval only sees the top-level environment.  It may be possible to use 
the environments egg to construct your own environment containing v.

Cheers,
Peter
-- 
http://sjamaan.ath.cx
--
"The process of preparing programs for a digital computer
 is especially attractive, not only because it can be economically
 and scientifically rewarding, but also because it can be an aesthetic
 experience much like composing poetry or music."
                                                        -- Donald Knuth

Attachment: pgp46zmYby3Pa.pgp
Description: PGP signature


reply via email to

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