Subject: bug#37461: define-generic doesn't promote equal? to generic

From: Mikael Djurfeldt <[email-masked]>
Date: Mon, 23 Sep 2019 17:01:40 +0200

Hi Rob,

I left GOOPS development at Guile version 1.8. The way this was then
intended to work was that

  (define-generic equal?)

means that you want to create a new generic equal?. This discards the old
binding for equal?.

  (define-method (equal? (a <string>) (b <string>)) ...)

on the other hand, means that you want to *extend* the current behavior of
equal? with a specialization to two strings. The method is then added to
equal?, which in guile-1.8 was from scratch a "primitive-generic".

Here's the actual output of guile-1.8:

guile> equal?
#<primitive-generic equal?>
guile> (use-modules (oop goops))
guile> (define-method (equal? (a <string>) (b <string>)) (string=? a b))
guile> equal?
#<primitive-generic equal?>
guile> (primitive-generic-generic equal?)
#<<generic> equal? (2)>
guile> (define-generic equal?)
guile> equal?
#<<generic> equal? (0)>

I don't know if the changes between 1.8 and 2.2.6 is intentional or a bug.
Does someone here know?

Best regards,
Mikael

On Sat, Sep 21, 2019 at 7:09 PM Rob Browning <[email-masked]> wrote:

> Rob Browning <[email-masked]> 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.
>
> Perhaps there was something else going on, but now :replace does appear
> to work, e.g. if I define a completely new generic and then
>
>   (define equal? new-equal)
>
> a "replace: (equal?)" in the define-module does appear to work when you
> use the module.
>
> Though define-method still ignores attempts to specialize (or change the
> specialization) for existing types like <string>, etc. (as mentioned in
> my other message).
>
> 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
>
>
>
>