From: Kenny Tilton
Subject: Customized reader methods via AMOP?
Date: 
Message-ID: <37D8E87E.2D961641@liii.com>
OK, my next adventure is specializing slot access for my metaclass.

I am using ACL 5.0.

After encountering some problems with my preferred attack point,
SLOT-VALUE-USING-CLASS (I have a Q into Franz tech support) with a lot
of time pressure I decided to punt and just automatically generate
readers and writers to achieve nearly the same end. i wante dto
automatically generate for:

  (defclass xxx ()
    ((aa :reader aa))
    (:metaclass myMClass))

the moral equivalent of:

  (defmethod aa ((self xxx))
    (myMClass-slot-value self 'aa))

I am close, but so far only a bizarre glimmer of success I won't even
mention, it was that bad. :)

This much was easy enough:

 (defclass DFReader (standard-reader-method)())

 (defmethod reader-method-class ((dfc DataflowClass) (dsd DataflowDSD)
&rest iargs)
   (find-class 'dfreader))

Sure enough, the readers under my metaclass are all 'DFReader...now
what? I do not see how to supply the /body/ of the method. My one weird
success (OK, I'll mention it) was setf'ing the method function slot via
(setf slot-value)...it ould work once but then go away.

I also tried cooking up methods this way:

           (make-instance 'DFReader
                    :generic-function gf ;; the generic function
                    :lambda-list '(self)
                    :qualifiers ()
                    :slot-definition dsd ;; the direct slot def
                    :slot-name slotName
                    :specializers (list class)
                    :function #'(lambda (self)
                                  (print "Bingo!")
                                  (slot-value self slotname)))

Well, it gets in there OK, but if I then loop thru the Generic function
methods removing all others so only this remains, then attempt to access
a slot with the usual reader syntax, I get an error: No applicable
method, tho as I examine it in the inspector it looks good to me.

BTW, 'add-reader-method does not seem to allow me to specify the method
body.

Oh, well, my pre-metaclass incarnation was a huge macro that did the
same, so that's what I will do next, but I sure would like to get this
metaclass thing working on the up-and-up. It's neat.

Thx for any insights.

Kenny Tilton
CliniSys