This is the mail archive of the guile@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: need SETQ


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]