Newsgroups: comp.lang.lisp
Path: cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!newsfeed.pitt.edu!gatech!swrinde!howland.reston.ans.net!vixen.cso.uiuc.edu!uwm.edu!newsspool.doit.wisc.edu!night.primate.wisc.edu!aplcenmp!hall
From: hall@aplcenmp.apl.jhu.edu (Marty Hall)
Subject: Re: Q: setf and structures
Message-ID: <DnHnrw.I4w@aplcenmp.apl.jhu.edu>
Organization: JHU/APL Research Center, Hopkins P/T CS Faculty
References: <4h0950$quo@gatekeeper.tasb.org>
Distribution: inet
Date: Wed, 28 Feb 1996 13:50:19 GMT
Lines: 41

In article <4h0950$quo@gatekeeper.tasb.org> beal_bob@tasb.org writes:
[...]
>(defstruct thing x y z)
>(setq *things* (list (make-thing :x 5) (make-thing :x 10) (make-thing :x 15)))
[...]
>Okay.  Now how do I do the same thing to *set* the slots?
>I want to do something like this:
>
>(mapc #'set-thing-x *things* '(8 12 16))  => sets :x slots to 8, 12, 16

(I tried emailing but it bounced)

I assume you already know you could do

(mapc #'(lambda (Thing X-Val) (setf (thing-x Thing) X-Val))
      *things*
      '(8 12 16))

>In other words, what is the "name" of the structure update function so
>that I can pass it to a mapping function?

With CLOS generic functions, the name of the function is actually
(setf XXX) if there is an accessor of that form. Eg:

(defclass Foo ()
  ((A :initform 4 :accessor A)))

(setq *Foos* 
  (list (make-instance 'Foo) (make-instance 'Foo) (make-instance 'Foo)))

(mapcar #'A *Foos*) --> (4 4 4)

(mapc #'(setf A) '(5 6 7) *Foos*)   ; Note values first, objects second

(mapcar #'A *Foos*) --> (5 6 7)

But I doubt you will have anything like this with Interleaf Lisp, so
stick with the lambda-form method there. 
						- Marty

Common Lisp Intro: http://www.apl.jhu.edu/~hall/lisp.html
