* [PATCH] GOOPS MOP no-method doesn't work
@ 2004-01-25 18:03 Andreas Rottmann
2004-02-19 21:48 ` Mikael Djurfeldt
0 siblings, 1 reply; 2+ messages in thread
From: Andreas Rottmann @ 2004-01-25 18:03 UTC (permalink / raw)
[-- Attachment #1: Type: text/plain, Size: 887 bytes --]
Hi!
I noticed that besides that <generic> specialization does not work
(see [0], this is apparently related to bugs/goops-apply-generic), the
no-method generic isn't invoked, because the C-based protocol does not
use it at all. Here is an example:
guile> (use-modules (oop goops))
guile> (define-generic foobar)
guile> (foobar)
Backtrace:
In current input:
3: 0* [foobar]
<unnamed port>:3:1: In procedure foobar in expression (foobar):
<unnamed port>:3:1: No applicable method for #<<generic> foobar (0)> in call (foobar)
ABORT: (goops-error)
guile>
According to the MOP, no-method should be invoked, which in turn would
yield another error message (from oop/goops.scm):
(define-method (no-method (gf <generic>) args)
(goops-error "No method defined for ~S" gf))
The following small patch fixes the issue; however, I'm not sure if I
added the code "at the right place":
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Fix to make GOOPS use no-method --]
[-- Type: text/x-patch, Size: 409 bytes --]
Index: oop/goops/dispatch.scm
--- oop/goops/dispatch.scm
+++ oop/goops/dispatch.scm
@@ -211,6 +211,8 @@
(define (memoize-method! gf args exp)
(if (not (slot-ref gf 'used-by))
(slot-set! gf 'used-by '()))
+ (if (null? (slot-ref gf 'methods))
+ (no-method gf args))
(let ((applicable ((if (eq? gf compute-applicable-methods)
%compute-applicable-methods
compute-applicable-methods)
[-- Attachment #3: Type: text/plain, Size: 297 bytes --]
Andy
--
Andreas Rottmann | Rotty@ICQ | 118634484@ICQ | a.rottmann@gmx.at
http://yi.org/rotty | GnuPG Key: http://yi.org/rotty/gpg.asc
Fingerprint | DFB4 4EB4 78A4 5EEE 6219 F228 F92F CFC5 01FD 5B62
Python is executable pseudocode, Perl is executable line-noise.
[-- Attachment #4: Type: text/plain, Size: 136 bytes --]
_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://mail.gnu.org/mailman/listinfo/bug-guile
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] GOOPS MOP no-method doesn't work
2004-01-25 18:03 [PATCH] GOOPS MOP no-method doesn't work Andreas Rottmann
@ 2004-02-19 21:48 ` Mikael Djurfeldt
0 siblings, 0 replies; 2+ messages in thread
From: Mikael Djurfeldt @ 2004-02-19 21:48 UTC (permalink / raw)
Cc: Guile Bugs, djurfeldt, mvo
Andreas Rottmann <a.rottmann@gmx.at> writes:
> I noticed that besides that <generic> specialization does not work
> (see [0], this is apparently related to bugs/goops-apply-generic), the
> no-method generic isn't invoked, because the C-based protocol does not
> use it at all. Here is an example:
Thanks for your patch. However, I think we should deprecate no-method
rather than put it in the MOP. It doesn't seem particularly useful to
have a function which is called only if you try to invoke a generic
which totally lacks methods. I mean---it's such an exotic case.
It would be much more useful to have a function which is invoked
whenever there aren't any applicable methods for a generic. This is
also the choice made in CLOS.
M
_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://mail.gnu.org/mailman/listinfo/bug-guile
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-02-19 21:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-25 18:03 [PATCH] GOOPS MOP no-method doesn't work Andreas Rottmann
2004-02-19 21:48 ` Mikael Djurfeldt
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).