Path: utzoo!attcan!uunet!snorkelwacker!usc!cs.utexas.edu!hellgate.utah.edu!cdr.utah.edu!moore From: moore%cdr.utah.edu@cs.utah.edu (Tim Moore) Newsgroups: comp.lang.lisp Subject: Re: STRUCTUREP Message-ID: <1990Oct10.091722.4495@hellgate.utah.edu> Date: 10 Oct 90 15:17:22 GMT References: <753@forsight.Jpl.Nasa.Gov> Organization: University of Utah CS Dept Lines: 36 In article <753@forsight.Jpl.Nasa.Gov> gat@robotics.Jpl.Nasa.Gov (Erann Gat) writes: >Is there any way in Common Lisp to test if an object is a structure? There >doesn't seem to be a structurep function. > >E. Not portably. If your Common Lisp has a fully integrated CLOS, then (defun structurep (x) (typep (class-of x) 'structure-class)) should work. If not... Most implementations leave clues around that a given type is a structure; a glance at a structured type's property list can be instructive. From these clues you can construct your own structure-type-p, e.g. in Utah Common Lisp you could write (defun structure-type-p (x) (get x 'lisp::structure-info)) Then structurep is (defun structurep (x) (structure-type-p (type-of x))) Dick Waters' XP pretty printer uses this technique. Also, all implementations probably have a structure-p predicate that is not documented; you can root around with apropos and use it if you dare. Tim Moore moore@cs.utah.edu {bellcore,hplabs}!utah-cs!moore "Ah, youth. Ah, statute of limitations." -John Waters