GNU bug report logs - #37461
Methods added to primitive generics don't always work

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guile; Reported by: Rob Browning <rlb@HIDDEN>; dated Thu, 19 Sep 2019 15:38:02 UTC; Maintainer for guile is bug-guile@HIDDEN.
Changed bug title to 'Methods added to primitive generics don't always work' from 'define-generic doesn't promote equal? to generic' Request was from Rob Browning <rlb@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 37461 <at> debbugs.gnu.org:


Received: (at 37461) by debbugs.gnu.org; 21 Sep 2019 15:15:43 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Sep 21 11:15:42 2019
Received: from localhost ([127.0.0.1]:33113 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iBh6s-0005EN-I1
	for submit <at> debbugs.gnu.org; Sat, 21 Sep 2019 11:15:42 -0400
Received: from defaultvalue.org ([45.33.119.55]:47196 ident=postfix)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rlb@HIDDEN>)
 id 1iBh6r-0005ED-7W; Sat, 21 Sep 2019 11:15:41 -0400
Received: from trouble.defaultvalue.org (localhost [127.0.0.1])
 (Authenticated sender: rlb@HIDDEN)
 by defaultvalue.org (Postfix) with ESMTPSA id 5EDA320317;
 Sat, 21 Sep 2019 10:15:40 -0500 (CDT)
Received: by trouble.defaultvalue.org (Postfix, from userid 1000)
 id D20C414E068; Sat, 21 Sep 2019 10:15:41 -0500 (CDT)
From: Rob Browning <rlb@HIDDEN>
To: 37461 <at> debbugs.gnu.org
Subject: Re: bug#37461: define-generic doesn't promote equal? to generic
In-Reply-To: <87blvfzx1f.fsf@HIDDEN>
References: <87lfukz48d.fsf@HIDDEN>
 <87blvfzx1f.fsf@HIDDEN>
Date: Sat, 21 Sep 2019 10:15:41 -0500
Message-ID: <87lfuh3cki.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 37461
Cc: control <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

retitle 37461 Methods added to primitive generics don't always work
thanks

Rob Browning <rlb@HIDDEN> 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




Information forwarded to bug-guile@HIDDEN:
bug#37461; Package guile. Full text available.

Message received at 37461 <at> debbugs.gnu.org:


Received: (at 37461) by debbugs.gnu.org; 19 Sep 2019 23:27:59 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Sep 19 19:27:59 2019
Received: from localhost ([127.0.0.1]:56571 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iB5qB-0004W9-E1
	for submit <at> debbugs.gnu.org; Thu, 19 Sep 2019 19:27:59 -0400
Received: from defaultvalue.org ([45.33.119.55]:47122 ident=postfix)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rlb@HIDDEN>) id 1iB5q9-0004W0-G9
 for 37461 <at> debbugs.gnu.org; Thu, 19 Sep 2019 19:27:58 -0400
Received: from trouble.defaultvalue.org (localhost [127.0.0.1])
 (Authenticated sender: rlb@HIDDEN)
 by defaultvalue.org (Postfix) with ESMTPSA id 6C1732008A
 for <37461 <at> debbugs.gnu.org>; Thu, 19 Sep 2019 18:27:56 -0500 (CDT)
Received: by trouble.defaultvalue.org (Postfix, from userid 1000)
 id 95D6D14E068; Thu, 19 Sep 2019 18:27:56 -0500 (CDT)
From: Rob Browning <rlb@HIDDEN>
To: 37461 <at> debbugs.gnu.org
Subject: Re: define-generic doesn't promote equal? to generic
In-Reply-To: <87lfukz48d.fsf@HIDDEN>
References: <87lfukz48d.fsf@HIDDEN>
Date: Thu, 19 Sep 2019 18:27:56 -0500
Message-ID: <87blvfzx1f.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 37461
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Rob Browning <rlb@HIDDEN> writes:

> You can work around the problem by stashing equal? somewhere else, and
> then define-generic will work after a (define equal? #f).  Presumably
> you'd then need to define a base specialization using the original
> equal? or do something equivalent.

It looks like while this works within a module, I haven't figured out
any workaround that allows the module to present the resulting generic
equal? to code that uses the module.

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.

-- 
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




Information forwarded to bug-guile@HIDDEN:
bug#37461; Package guile. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 19 Sep 2019 15:37:59 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Sep 19 11:37:59 2019
Received: from localhost ([127.0.0.1]:56289 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iAyVL-00016L-Fg
	for submit <at> debbugs.gnu.org; Thu, 19 Sep 2019 11:37:59 -0400
Received: from lists.gnu.org ([209.51.188.17]:42815)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rlb@HIDDEN>) id 1iAyVJ-00016D-LR
 for submit <at> debbugs.gnu.org; Thu, 19 Sep 2019 11:37:58 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:36913)
 by lists.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <rlb@HIDDEN>) id 1iAyVI-0002Xi-B9
 for bug-guile@HIDDEN; Thu, 19 Sep 2019 11:37:57 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,URIBL_BLOCKED
 autolearn=disabled version=3.3.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <rlb@HIDDEN>) id 1iAyVH-0000Cn-75
 for bug-guile@HIDDEN; Thu, 19 Sep 2019 11:37:56 -0400
Received: from defaultvalue.org ([45.33.119.55]:39460)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <rlb@HIDDEN>) id 1iAyVH-0000CN-1t
 for bug-guile@HIDDEN; Thu, 19 Sep 2019 11:37:55 -0400
Received: from trouble.defaultvalue.org (localhost [127.0.0.1])
 (Authenticated sender: rlb@HIDDEN)
 by defaultvalue.org (Postfix) with ESMTPSA id 368262015C
 for <bug-guile@HIDDEN>; Thu, 19 Sep 2019 10:37:54 -0500 (CDT)
Received: by trouble.defaultvalue.org (Postfix, from userid 1000)
 id 763EC14E068; Thu, 19 Sep 2019 10:37:54 -0500 (CDT)
From: Rob Browning <rlb@HIDDEN>
To: bug-guile@HIDDEN
Subject: define-generic doesn't promote equal? to generic
Date: Thu, 19 Sep 2019 10:37:54 -0500
Message-ID: <87lfukz48d.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 45.33.119.55
X-Spam-Score: -1.4 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.4 (--)


Version: 2.2.6

  scheme@(guile-user)> (use-modules (oop goops))
  scheme@(guile-user)> equal?
  $1 = #<procedure equal? (#:optional _ _ . _)>
  scheme@(guile-user)> (define-generic equal?)
  scheme@(guile-user)> equal?
  $2 = #<procedure equal? (#:optional _ _ . _)>

The same appears to be true for other primitives like + too, but if I'm
reading it right, this makes it sound like it was intended to work:

  https://www.gnu.org/software/guile/docs/master/guile.html/Extending-Primitives.html

You can work around the problem by stashing equal? somewhere else, and
then define-generic will work after a (define equal? #f).  Presumably
you'd then need to define a base specialization using the original
equal? or do something equivalent.

I also noticed goops itself does this: https://git.savannah.gnu.org/gitweb/?p=guile.git;a=blob;f=module/oop/goops.scm;h=837a667e602\
5b6f8ed7818e5a8efe064cca7843d;hb=791cae940afcb2b2eb2c167fe438be1dc1008a73#l2335

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




Acknowledgement sent to Rob Browning <rlb@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-guile@HIDDEN. Full text available.
Report forwarded to bug-guile@HIDDEN:
bug#37461; Package guile. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sat, 21 Sep 2019 15:30:01 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.