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

Re: Type hierarchy AND: does a portable solution exist?



Hi,

 > From: lbaum@BOEING.COM (Larry Baum)
 
 > I have a hierarchy of structure types.  I wish to display the hierarchy
 > ...
 > I would like to do: (structure-children 'air-object) -> (AIRPLANE BLIMP BIRD)

(defstruct blimb)
(defstruct (ablimb (:include blimb)))

This solution is Lisp implementation dependent (Genera rel. 7.2):

(defun defstruct-included-struct (symbol)
  (si::defstruct-description-include
    (get symbol 'si::defstruct-description)))

(defstruct-included-struct 'blimb)  ; => NIL
(defstruct-included-struct 'ablimb) ; => (BLIMB)

>From this it is not too far to construct STRUCTURE-CHILDREN...

---- 

Writing this, I wonder what could be done in a portable way ...  

To my knowledge you can't expect to find some way to compute the
included structure's symbol in all CL implementations. CLtL does not
promise anything like this.  Assume you know the symbols of interest --
worst case: do-symbols for a few packages -- I thought

 (subtypep 'ablimb 'blimb) => T   [actually what Lucid CL on SUN does]
 
might give some access to the subtype relation and could be used to
FORMAT-GRAPH it, but CLtL is very specific on SUBTYPEP. It says
definitely you cannot rely on SUBTYPEP:

 (subtypep 'ablimb 'blimb) => NIL NIL   [the result in Rel 7.2]

is always possible and indicates (second value) that the implementor
is/was uncertain whether SUBTYPEP returns the correct (first) value.
What a promise! On the other hand, the CLtL notion of subtype seems
to be related to the representation type chosen by an implementation
rather than the abstract type in Larry's type hierarchy.

Anyway, heard some rumors on cleanup proposals for Common Lisp
especially in the CL type system and in particular in view of the CLOS
integration with the standard.  I don't know details about these cleanups though.  
Only my CLOS spec (X3J13 88-002R accepted by the cleanup committee)
says something like
 (1) structures are classes
 (2) more specifically, structures are instances of STRUCTURE-CLASS
 (2) :include creates a subclass in the sense of CLOS. 
Hence 
 (4) CLASS-PRECEDENCE-LIST might be used in a (future) portable solution.

Anybody out there who knows a *portable* solution for Larry's problem?

  --hws

Heinz W. Schmidt				UUCP: hws@gmdzi.UUCP
German National Research Center			Tel:  (++49 2241) 14-2448
for Computer Science (GMD),
Institut fuer Systemtechnik                
Postf. 1240
D-5205 St. Augustin 1, FRG