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

Defstruct doldrums

   From: eliot@winnie.Princeton.EDU (eliot handelman)

   I need to know how to map over the slots of random structures. Supposing
   this were called MAPSTRUCT, taking a function and a structure, it would
   feed the contents of each slot (and perhaps also the slot-name) to the 

   This is how it has to behave:

   > (mapstruct #'(lambda (slot slotname) (list slot slotname))
		(make-flibber :a 1 :b 2))

   ((A 1) (B 2))

   I need this because I'm trying to port something originally written in
   KCl to Allegro. In KCl structures are vectors, and you can figure out
   everything you need from the structure plist, but in Allegro the plist
   is, I see, also a structure whose print form doesn't tell me anything.

   I'm using Allegro on the Next.

On present versions of Allegro you can treat "untyped" (that is,
default typed) defstructs as vectors.  LENGTH will return the number
of slots.  SVREF (and SETF thereof) will operate correctly.  The
zeroth slot is the symbol naming the structure, and the remaining
vector slots are the defstruct slots.

Of course, this functionality of LENGTH and SVREF aren't provided by
any CL spec and therefore might disappear or change in a future

   --Eliot Handelman
     Music Dept,
     Princeton U.

Say hello to Paul Lansky for me.