[Top][All Lists]

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

Dynamic variable binding

From: Sebastian Tennant
Subject: Dynamic variable binding
Date: Wed, 12 Nov 2008 19:53:03 +0000
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/22.2 (gnu/linux)

Hi all,

An elementary scheme problem from an elementary schemer...

I need to create multiple variable bindings from a list of symbols.  The
value of the variables is unimportant.  It's the 'names' of the
variables that matter.

In pseudo-scheme code:

  (map (lambda (v) (define (eval v) "foo") '(var1 var2 var3)))

Clearly this won't work but I thought perhaps calling a macro in place
of the 'define' would do it, but...

 guile> (define-macro (definer var val)
          `(define ,var ,val))
 guile> (definer 'foo "bar")
 guile> foo
 ERROR: Unbound variable: foo
 ABORT: (unbound-variable)

No doubt this fails for the same reason this does:

 guile> (define 'foo "bar")
 guile> foo
 ERROR: Unbound variable: foo
 ABORT: (unbound-variable)

What exactly happens when you 'define' a symbol?

Any tips/pointers much appreciated.


reply via email to

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