This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: need SETQ
- To: PILCH Hartmut <phm at a2e dot de>
- Subject: Re: need SETQ
- From: Dirk Herrmann <dirk at ida dot ing dot tu-bs dot de>
- Date: Fri, 4 Feb 2000 18:21:55 +0100 (MET)
- cc: scsh at zurich dot ai dot mit dot edu, guile at sourceware dot cygnus dot com
On Fri, 4 Feb 2000, PILCH Hartmut wrote:
> Can anybody post a Standard Scheme Macro that does what SETQ of Common
> Lisp does?
On January, 20th you had already brought up this topic, which can be
verified at the guile mailing list archive at
http://sourceware.cygnus.com/ml/guile/2000-01/msg00302.html
After that, a lot of discussion of the whole topic went on. One of the
first posts (by Michael Livshin on January 20th) gave _two_ alternative
macro implementations of setq for guile.
http://sourceware.cygnus.com/ml/guile/2000-01/msg00307.html
I take the freedom to quote his code, which, however, I did not try for
myself:
(defmacro setq (var val)
(let ((tname (gensym)))
`(let ((,tname ,val))
(set! ,var ,tname)
,tname)))
-or-
(use-syntax (ice-9 syncase))
(define-syntax setq
(syntax-rules ()
((setq var val)
(let ((tmp val))
(set! var tmp)
tmp))))
Also, the aspect of scheme being a functional language (or not) and
reasons for why set! is defined the way it is has been discussed in that
thread.
I expect people to follow the discussions they initiate.
Best regards
Dirk Herrmann