Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!usc!elroy.jpl.nasa.gov!forsight!gat From: gat@robotics.Jpl.Nasa.Gov (Erann Gat) Newsgroups: comp.lang.lisp Subject: Re: STRUCTUREP Message-ID: <755@forsight.Jpl.Nasa.Gov> Date: 10 Oct 90 20:28:24 GMT References: <753@forsight.Jpl.Nasa.Gov> <27133D6E.715C@marob.masa.com> Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 35 In article <27133D6E.715C@marob.masa.com>, cowan@marob.masa.com (John Cowan) writes: > 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. > > No, there isn't, and that's intentional. Some of the Common Lisp standard > types, notably STREAM, READTABLE, RANDOM-STATE, PATHNAME, and PACKAGE > may be implemented using the structure mechanism, but this fact is hidden > from the user. A STRUCTUREP function would be unable to discriminate > between these implementation-defined structures and user-defined ones. Oh, come on! Since the implementation gets to define structurep, it can make explicit checks to exclude other types which the implementation implements as structures. It may not be pretty or efficient, but it's certainly not impossible! > There's very little you can say about a structure qua structure, anyway. > The names of the {access, constructor} functions aren't deducible from the > outside, given that the default names can be overridden at DEFSTRUCT time. This strikes me as another severe deficiency in Common Lisp. Suppose I wanted to write a function that took an arbitrary structure and printed out all the slot names and values. This can't be done in CL, but the inspector can do it so the underlying capability must be there (at least in every implementation I've ever used). This is another example of something that can be done in T but not in CL. (BTW, this function might want to be able to check that its argument was indeed a structure before proceeding.) None of these "impossible" or "impractical" arguments will stand up. It is possible to implement a T-style structure system within Common Lisp. (The details are left as an excercise for the reader.) Perhaps structurep will appear in CLTL3. (Perhaps everyone will see the light and start using T. Perhaps we can banish Fortran. Perhaps the horse will sing. :->) E.