[Top][All Lists]

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

Re: [1.6.4 GOOPS] no (next-method) in accessor?

From: Andy Wingo
Subject: Re: [1.6.4 GOOPS] no (next-method) in accessor?
Date: Mon, 26 Jul 2004 18:51:20 +0100

Hey Steve,

I looked at your code. I'm no expert, but here's what I see.

On Sun, 2004-07-25 at 17:17 -0400, Steve Tell wrote:
> In a subclasse's accessor's #:slot-set! routine

Here's where you go wrong. The slot-set! routine is not a generic
function, nor does it belong to the accessor. Instead, these arguments
to `make-class' are used by the default compute-get-n-set generic, which
uses them to explicitly set the get/set functions for a class.

There is no MOP specified for get and set functions, though. If you
wanted to implement something like this, you could define a metaclass
for the root <ctrlpt> class that implements a custom compute-get-n-set

Here's some code from (gnome gobject gtype), as an example:

(define-class <set-once-class> (<class>))
(define-method (compute-get-n-set (class <set-once-class>) s)
  (case (slot-definition-allocation s)
     (create-set-once-g-n-s class s #f)) ;; returns (list getter setter)

     (create-set-once-g-n-s class s #t))

    ;; Chain up for the default allocation methods...
    (else (next-method))))

;; We have to inherit from class because we're a metaclass. We do that
;; via <set-once-class>. We have #:set-once slots, so we also need to
;; have <set-once-class> as our metaclass.
(define-class <gtype-class> (<set-once-class>)
  (gtype #:allocation #:set-once)
  (gtype-class #:allocation #:set-once)
  #:metaclass <set-once-class>)

In your case, since <ctrlpt> isn't a metaclass the supers list would be

Hope this helps,
Andy Wingo <address@hidden>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]