unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Mikael Djurfeldt <mikael@djurfeldt.com>
To: Rob Browning <rlb@defaultvalue.org>
Cc: 37461@debbugs.gnu.org
Subject: bug#37461: define-generic doesn't promote equal? to generic
Date: Sat, 28 Sep 2019 18:51:43 +0200	[thread overview]
Message-ID: <CAA2XvwJmS5B700nGiSgRN-D1_kk1PwAi_M5HqBmZJ+qvs7Z3OA@mail.gmail.com> (raw)
In-Reply-To: <CAA2XvwK_C8UULe4h=DBOHPvHibad=iNCjjOJfeoT_mnO-VSVxA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1446 bytes --]

On Mon, Sep 23, 2019 at 5:01 PM Mikael Djurfeldt <mikael@djurfeldt.com>
wrote:

>
>   (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".
>
> Actually, this is misguided. I should have examined this problem more
carefully, and also read your later emails more carefully.

You see, I was under the impression that primitive-generic capability had
been removed for equal?. It has not. It's only the printed representation
which has changed.

Your bug report contains two problems. One concerns why define-generic
doesn't create a new generic. I believe this is an intentional or
unintentional change at some version. The other problem concerns the
dispatch rules for primitive generics.

You are right that the dispatch rules are special for primitive generics.
The purpose of primitive generics is to get around any performance penalty
for standard behavior, so primitive generics first try standard dispatch.
Then, if that fails, GOOPS method dispatch is used. The standard behavior
of equal? is to simply return #t when applied to a single argument
regardless of type. This is the explanation why you get #t for (equal?
<foo>).

One way to view this is that the dispatch of primitive-generics is
partially constrained.

[-- Attachment #2: Type: text/html, Size: 1919 bytes --]

  reply	other threads:[~2019-09-28 16:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-19 15:37 bug#37461: define-generic doesn't promote equal? to generic Rob Browning
2019-09-19 23:27 ` Rob Browning
2019-09-21 15:15   ` Rob Browning
2019-09-21 17:08   ` Rob Browning
2019-09-23 15:01     ` Mikael Djurfeldt
2019-09-28 16:51       ` Mikael Djurfeldt [this message]
2019-09-28 17:31         ` Rob Browning

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=CAA2XvwJmS5B700nGiSgRN-D1_kk1PwAi_M5HqBmZJ+qvs7Z3OA@mail.gmail.com \
    --to=mikael@djurfeldt.com \
    --cc=37461@debbugs.gnu.org \
    --cc=rlb@defaultvalue.org \
    /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).