[Top][All Lists]

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

syntax-rules and conditional define

From: Kevin Ryde
Subject: syntax-rules and conditional define
Date: Sat, 15 Feb 2003 08:49:22 +1000
User-agent: Gnus/5.090013 (Oort Gnus v0.13) Emacs/21.2 (i386-pc-linux-gnu)

In guile 1.6.3 on a recent i386 debian, I thought to make myself a
"define if not already defined" using

    (use-modules (ice-9 syncase))
    (define-syntax define-maybe
      (syntax-rules ()
        ((define-maybe name value)
         (if (not (defined? 'name))
             (define name value)))))

    (define-maybe x 123)

but run with "guile -s foo.scm" gives

    /down/guile/usr/share/guile/1.6/ice-9/syncase.scm:130:16: In procedure 
scm-error in expression (scm-error (quote misc-error) who ...):
    /down/guile/usr/share/guile/1.6/ice-9/syncase.scm:130:16: invalid context 
for definition of x

I guess I'm not sure if this is a bug, but

    (if (not (defined? 'x))
        (define x 123))

worked at the top-level, so I thought perhaps it could be expected to
in a macro too.

reply via email to

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