scsh-users
[Top] [All Lists]

Re: need SETQ

To: PILCH Hartmut <phm@a2e.de>
Subject: Re: need SETQ
From: Dirk Herrmann <dirk@ida.ing.tu-bs.de>
Date: Fri, 4 Feb 2000 18:21:55 +0100 (MET)
Cc: scsh@zurich.ai.mit.edu, guile@sourceware.cygnus.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


<Prev in Thread] Current Thread [Next in Thread>