Re: Opaque objects and introspection

From: <kanderso_at_BBN.COM>
Date: Wed, 17 May 95 09:43:59 -0400

  
> Ken Anderson writes
> I had several questions about the intent of stklos in several areas:
>
> Q1. Opaqueness. The original Tiny CLOS metaobjects were unnamed. This
  ...
  
  This is changed now since printing can be done by two method which are called
  display-object and write-object. The method Tk-write-object is even used when
  an object is passed to Tk. The code of stklos.stk is now
  
  ;;; Write
  (define-method write-object (o file)
    (format file "#[~S ~A]" (class-name (class-of o)) (address-of o)))
  
  (define-method write-object((self <class>) file)
     (format file "#[~A ~A]" (class-name (class-of self))
                                (class-name self)))
  
  ;;; Display (do the same thing as write by default)
  (define-method display-object (o file)
    (write-object o file))
  
OK, so write and display call write-object and display-object, sounds good.

  ...
> Q2. Method names. <method>'s have a name slot, but it is currently
> unbound. What is the intent of this slot. Should it be the name of the
> generic function? It looks like the method macro has a bug in it, and
> (method initailize (<method>)) does not bind the name slot.
  
  I had not seen the problem before and I will try to correct it.
  
I played with this a little. I made the name slot in method be the name of
the generic-function. However, i belive it would be better if the slot was
called generic-function and actually held the generic function rather than
a name.

  ...
  
> Q4. Limits of introspection. In CLOS, i can start at the top of the class
> hierarchy (the class T) and pretty much find out anything i want. This
> can't be done in STklos. For example, in CLOS given a class, i can find
> all methods specialized on this class. In STklos, i can't. Is this the
> way it should be?
  I'm not against this idea if you can tell me why this is useful.
  For me, the fact to find a method starting from a class seems to go againt the
  notion of generic function which are expliciteley defined outside of classes.
  The only interest I see for this is for browsers.
  Or is there a point I have missed?
  
Browsing is just one example of the kind of introspection one might want to
do. Another example is to support automatic extensions or optimizations.
One optimization i do in Common Lisp is to identify accessor generic
functions which can be optimized into a type test and a vector-ref at a
fixed offset.

I can add what i need either by redefining the define-* macros or using my
own metaclasses. However, if such introspection is valuable enough to be
used in many applications, then perhaps the base language should support
it. I would certainly recommend adding CLASS-DIRECT-SUBCLASSES which would
allow one to browse down the class hierarchy. Adding functions:

class-direct-subclasses
class-direct-methods
method-generic-function

would at least provide the same basic introspection facilities that CLOS
has.

k
Received on Wed May 17 1995 - 15:47:45 CEST

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST