Path: utzoo!attcan!uunet!samsung!zaphod.mps.ohio-state.edu!usc!elroy.jpl.nasa.gov!forsight!gat From: gat@robotics.Jpl.Nasa.Gov (Erann Gat) Newsgroups: comp.lang.lisp Subject: Re: STRUCTUREP Message-ID: <759@forsight.Jpl.Nasa.Gov> Date: 11 Oct 90 18:24:09 GMT References: <1990Oct10.091722.4495@hellgate.utah.edu> <2713DF17.555@ics.uci.edu> Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 31 In article <2713DF17.555@ics.uci.edu>, pazzani@ics.uci.edu (Michael Pazzani) writes: > If you get to define the structures (rather than using a large existing > program), you could do this in a different way: > > (defstruct struct) ;; It has no slots, but a struct-p is created > > now just include struct in every structure you care about, and struct-p > will work on them. If I get to define all the structures then I could just as easily just check for all the structure types that I have derfined. There's no sport in that. I want to be able to tell if someone else's data object is a structure. There is actually a portable definition of structurp which no one seems to have thought of. The number of core data types in Common Lisp is finite. Therefore, one can check to see if an object is a structure simply by checking that it is NOT anything else. i.e. something like (defun structurep (object) (and (not (numberp object)) (not (consp object)) (not (symbolp object)) ... [ probably ten or fifteen more would do ] (commonp object))) Of course, in CLTL2 they took out commonp (on the grounds that it wasn't useful for anything!) but they added CLOS which lets you test for structures in other ways. E.