[Top][All Lists]

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

Re: MOP question

From: Eric E Moore
Subject: Re: MOP question
Date: Wed, 24 Apr 2002 19:36:00 +0100
User-agent: Gnus/5.090004 (Oort Gnus v0.04) Emacs/21.2

Thien-Thi Nguyen <address@hidden> writes:

> next-method is bound in libguile/goops.c, 

After getting your message, I did manage to track it down, by, in
desperation, grepping the source code for next-method, then working
backwards to find where it's bound.  It is bound by modifying the
source in compile-method (in oop/goops/compile.scm), which is called,
by way of some other functions, in memoize-method! (in dispatch.scm)
which is called from the C code (in eval.c via scm_memoize_method)


>  *    - a hard-coded MOP for standard gf, which can be overloaded for non-std 
> gf


>  * Protocol for calling a generic fumction
>  * This protocol is roughly equivalent to (parameter are a little bit 
> different
>  * for efficiency reasons):
>  *
>  *    + apply-generic (gf args)
>  *            + compute-applicable-methods (gf args ...)
>  *                    + sort-applicable-methods (methods args)
>  *            + apply-methods (gf methods args)
>  *
>  * apply-methods calls make-next-method to build the "continuation" of a a
>  * method.  Applying a next-method will call apply-next-method which in
>  * turn will call  apply again to call effectively the following method.

apply-generic does not seem to ever be called, so I'm not sure what
overriding it would do.  (since calling apply-generic on a gf directly
doesn't work, I suspect it's not being called is currently a good
thing).  apply-methods doesn't work either...  Nor can I even get:

(use-modules (oop goops))
(define-class <my-generic> (<generic>))
(define a-my-generic (make <my-generic> #:name 'a-my-generic))
(define m (make <method> 
            #:specializers (list <top>)
            #:procedure (lambda (x) 'foo)))
(add-method! a-my-generic m)

to work, as it complains about:

ERROR: In procedure %invalidate-method-cache!:
ERROR: Wrong type argument in position 1: #<<my-generic> a-my-generic (1)>
ABORT: (wrong-type-arg)

Fundamentally, it seems to me that the whole MOP for gf application is
broken, the method cache, and other optimizations in the C code have
bitrotted it into unusability.  I could be wrong, in which case I
would love someone to post code that does work :)

If I'm right, and if it can't be fixed soon (which looks like a bit of
a big task) maybe a note could go in the docs saying that it's not
working right now?

Eric E. Moore

Attachment: pgp4BJMKk75HY.pgp
Description: PGP signature

reply via email to

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