GNU bug report logs -
#37461
Methods added to primitive generics don't always work
Previous Next
Full log
View this message in rfc822 format
retitle 37461 Methods added to primitive generics don't always work
thanks
Rob Browning <rlb <at> defaultvalue.org> writes:
> A re-export doesn't affect the module using the re-exporter, and export
> and replace both fail with "Unbound variable: equal?", even though
> there's a (define equal? ...) in the module.
It looks like equal? isn't changed by define-generic, etc. because it
already has "generic-capability?". And in fact, I can see that defining
a method on it does alter its primitive-generic-generic, but then
dispatch to the new method doesn't always seem to work (or perhaps I
just misunderstand the dispatch rules).
Here a one argument specialization doesn't work, but a two argument
specialization does -- for new classes, but not for a "standard" class
like <string>:
scheme@(guile-user)> (use-modules (oop goops))
scheme@(guile-user)> (primitive-generic-generic equal?)
$1 = #<<generic> equal? (1)>
scheme@(guile-user)> (define-class <foo> () (data))
scheme@(guile-user)> (define-method (equal? (x <foo>)) 'x)
scheme@(guile-user)> (primitive-generic-generic equal?)
$2 = #<<generic> equal? (2)>
scheme@(guile-user)> (equal? (make <foo>))
$3 = #t
scheme@(guile-user)> (define-method (equal? (x <foo>) (y <foo>)) 'x)
$4 = #<<generic> equal? (3)>
scheme@(guile-user)> (equal? (make <foo>) (make <foo>))
$5 = x
scheme@(guile-user)> (define-method (equal? (x <string>) (y <string>)) 'x)
$6 = #<<generic> equal? (4)>
scheme@(guile-user)> (equal? "x" "y")
$7 = #f
Thanks
--
Rob Browning
rlb @defaultvalue.org and @debian.org
GPG as of 2011-07-10 E6A9 DA3C C9FD 1FF8 C676 D2C4 C0F0 39E9 ED1B 597A
GPG as of 2002-11-03 14DD 432F AE39 534D B592 F9A0 25C8 D377 8C7E 73A4
This bug report was last modified 5 years and 261 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.