unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Andy Wingo <wingo@pobox.com>
Subject: Re: [1.6.4 GOOPS] no (next-method) in accessor?
Date: Mon, 26 Jul 2004 18:51:20 +0100	[thread overview]
Message-ID: <1090864279.1307.15.camel@localhost> (raw)
In-Reply-To: <Pine.LNX.4.56.0407251701450.30652@ariel>

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
method.

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)
    ((#:set-once)
     (create-set-once-g-n-s class s #f)) ;; returns (list getter setter)

    ((#:set-once-each-subclass)
     (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
empty.

Hope this helps,
-- 
Andy Wingo <wingo@pobox.com>
http://ambient.2y.net/wingo/


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


      reply	other threads:[~2004-07-26 17:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-20 17:21 [GOOPS] Accessing a class slot Ludovic Courtès
2004-07-25 21:17 ` [1.6.4 GOOPS] no (next-method) in accessor? Steve Tell
2004-07-26 17:51   ` Andy Wingo [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1090864279.1307.15.camel@localhost \
    --to=wingo@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).