From unknown Sat Aug 16 16:21:30 2025 X-Loop: help-debbugs@gnu.org Subject: bug#26026: Defining a method named zero? breaks primitive zero? Resent-From: Alejandro Sanchez Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Wed, 08 Mar 2017 16:10:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 26026 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: 26026@debbugs.gnu.org X-Debbugs-Original-To: bug-guile@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.148898939618874 (code B ref -1); Wed, 08 Mar 2017 16:10:01 +0000 Received: (at submit) by debbugs.gnu.org; 8 Mar 2017 16:09:56 +0000 Received: from localhost ([127.0.0.1]:46504 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cleA0-0004uL-5b for submit@debbugs.gnu.org; Wed, 08 Mar 2017 11:09:56 -0500 Received: from eggs.gnu.org ([208.118.235.92]:50266) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1clZSR-0002Sb-Mg for submit@debbugs.gnu.org; Wed, 08 Mar 2017 06:08:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1clZSL-0007XF-J2 for submit@debbugs.gnu.org; Wed, 08 Mar 2017 06:08:34 -0500 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,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:33518) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1clZSL-0007XB-G1 for submit@debbugs.gnu.org; Wed, 08 Mar 2017 06:08:33 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41226) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1clZSK-0006xH-DZ for bug-guile@gnu.org; Wed, 08 Mar 2017 06:08:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1clZSF-0007Vr-JN for bug-guile@gnu.org; Wed, 08 Mar 2017 06:08:32 -0500 Received: from lb1.openmailbox.org ([5.79.108.160]:59792 helo=mail.openmailbox.org) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1clZSF-0007Up-Ab for bug-guile@gnu.org; Wed, 08 Mar 2017 06:08:27 -0500 Received: by mail.openmailbox.org (Postfix, from userid 20002) id 35B7251626F; Wed, 8 Mar 2017 12:07:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=openmailbox.org; s=openmailbox; t=1488971293; bh=hRnSclLA2XPDKOPKgaNwa/0x0//AH0vjQ193WV8Nhpg=; h=From:Subject:Date:To:From; b=t2t360ezEWwpxDuG+Qwxu/EO9y/KzQFLXeWbKEDjR2gsv0uxnanNXDNrGQqI5GoOc lYFcbcqMj/F0MGH/4HlAw9BhdGwfgT1rIUczcE5Kj7GdaaS5iDlLBOEMXXSj7S9DFL f2yYxu5i186CeACbK3lGfyMT1+UKXefqdBL03VWs= From: Alejandro Sanchez DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=openmailbox.org; s=openmailbox; t=1488971279; bh=hRnSclLA2XPDKOPKgaNwa/0x0//AH0vjQ193WV8Nhpg=; h=From:Subject:Date:To:From; b=FJ0MvSi3UtUxsv5cqYlc3UKDPNOEpDB6FPoRHhVkB4Uw1DJb3w/zv3mbDpsp9oBps JkovNbhmNvAiYLqi/6kduO34BEycz31vF+HYccAy8gs0IM+IAQRjUER/p4NSz6P6VW TqzdI99x1Yr/byZHzfynCTnMde/WUu9UraUL2aUE= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Message-Id: Date: Wed, 8 Mar 2017 12:07:56 +0100 Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) X-Mailer: Apple Mail (2.3124) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Mailman-Approved-At: Wed, 08 Mar 2017 11:09:55 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) If I define a =E2=80=98zero?=E2=80=99 predicate method for a custom = class the primitive =E2=80=98zero?=E2=80=99 is lost. Here is a simple = vector module: ;;; File vector2.scm (define-module (vector2) #:use-module (oop goops) #:export ( get-x get-y zero?)) =09 (define-class () (x #:init-value 0 #:getter get-x #:init-keyword #:x) (y #:init-value 0 #:getter get-y #:init-keyword #:y) ) (define-generic zero?) (define-method (zero? (v )) (and (zero? (get-x v)) (zero? (get-y v)))) In the Guile REPL try executing the following code: scheme@(guile-user)> (use-modules (oop goops) (vector2)) scheme@(guile-user)> (zero? (make )) This will display=20 WARNING: (guile-user): `zero?' imported from both (ice-9 r5rs) = and (vector2) ERROR: In procedure scm-error: ERROR: No applicable method for #< zero? (1)> in call = (zero? 0) =09 Entering a new prompt. Type `,bt' for a backtrace or `,q' to = continue. scheme@(guile-user) [1]> ,bt In vector2.scm: 11:7 2 (_ #< 105e87e00>) In oop/goops.scm: 1438:4 1 (cache-miss 0) In unknown file: 0 (scm-error goops-error #f "No applicable method for = ~S in call ~S" (#< =E2=80=A6) =E2=80=A6) Apparently the problem is that =E2=80=98zero?=E2=80=99 is defined in two = modules and the vector2 definition overrides it. This isn=E2=80=99t the = case with other primitives like =E2=80=98+=E2=80=99 or =E2=80=98*=E2=80=99= , so this seems like a bug? I had built Guile from HEAD a few days ago, = my package manager shows 6fff84d as the version number, so I guess that = must be the hash of the commit HEAD was pointing to at that time.= From unknown Sat Aug 16 16:21:30 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Alejandro Sanchez Subject: bug#26026: closed (Re: bug#26026: Defining a method named zero? breaks primitive zero?) Message-ID: References: <87mvbcl9df.fsf@igalia.com> X-Gnu-PR-Message: they-closed 26026 X-Gnu-PR-Package: guile Reply-To: 26026@debbugs.gnu.org Date: Wed, 19 Apr 2017 15:13:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1492614782-10630-1" This is a multi-part message in MIME format... ------------=_1492614782-10630-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #26026: Defining a method named zero? breaks primitive zero? which was filed against the guile package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 26026@debbugs.gnu.org. --=20 26026: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D26026 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1492614782-10630-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 26026-done) by debbugs.gnu.org; 19 Apr 2017 15:12:24 +0000 Received: from localhost ([127.0.0.1]:57050 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d0rHM-0002kX-0Y for submit@debbugs.gnu.org; Wed, 19 Apr 2017 11:12:24 -0400 Received: from pb-sasl1.pobox.com ([64.147.108.66]:50716 helo=sasl.smtp.pobox.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d0rHK-0002kP-9S for 26026-done@debbugs.gnu.org; Wed, 19 Apr 2017 11:12:22 -0400 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-sasl1.pobox.com (Postfix) with ESMTP id 22D2381D34; Wed, 19 Apr 2017 11:12:20 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; s=sasl; bh=aSNHcXs/Jy42 nyqcGHMOcvBDGJI=; b=Ivdk7hhSnqAF8xiBS3N2YhOBJ+O1g82seu9dWPWh7uxj UCTskJvv08zOVcP+STx3ySquDbkpXydhIVtHluE+90phIm007+6+JDdU8b90IyT7 DfkFDTmz1r7U9LWhTViwlZI1z1wuIftZwfCpbPZb8o64ylq1+YBihY8iJCU9Uy0= Received: from pb-sasl1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-sasl1.pobox.com (Postfix) with ESMTP id 1A44581D33; Wed, 19 Apr 2017 11:12:20 -0400 (EDT) Received: from rusty (unknown [88.160.190.192]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by pb-sasl1.pobox.com (Postfix) with ESMTPSA id 3F07681D32; Wed, 19 Apr 2017 11:12:19 -0400 (EDT) From: Andy Wingo To: Alejandro Sanchez Subject: Re: bug#26026: Defining a method named zero? breaks primitive zero? References: Date: Wed, 19 Apr 2017 17:12:12 +0200 In-Reply-To: (Alejandro Sanchez's message of "Wed, 8 Mar 2017 12:07:56 +0100") Message-ID: <87mvbcl9df.fsf@igalia.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Pobox-Relay-ID: 94C7C554-2512-11E7-A9B1-07D2064AB293-02397024!pb-sasl1.pobox.com X-Spam-Score: 0.7 (/) X-Debbugs-Envelope-To: 26026-done Cc: 26026-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.7 (/) On Wed 08 Mar 2017 12:07, Alejandro Sanchez write= s: > If I define a =E2=80=98zero?=E2=80=99 predicate method for a custom class= the primitive =E2=80=98zero?=E2=80=99 is lost. Here is a simple vector mod= ule: > > ;;; File vector2.scm > (define-module (vector2) > #:use-module (oop goops) > #:export ( get-x get-y zero?)) >=20=09 > (define-class () > (x #:init-value 0 #:getter get-x #:init-keyword #:x) > (y #:init-value 0 #:getter get-y #:init-keyword #:y) ) > > (define-generic zero?) > (define-method (zero? (v )) > (and (zero? (get-x v)) > (zero? (get-y v)))) > > In the Guile REPL try executing the following code: > > scheme@(guile-user)> (use-modules (oop goops) (vector2)) > scheme@(guile-user)> (zero? (make )) > > This will display=20 > > WARNING: (guile-user): `zero?' imported from both (ice-9 r5rs) and (vect= or2) > ERROR: In procedure scm-error: > ERROR: No applicable method for #< zero? (1)> in call (zero? 0) >=20=09 > Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue. > scheme@(guile-user) [1]> ,bt > In vector2.scm: > 11:7 2 (_ #< 105e87e00>) > In oop/goops.scm: > 1438:4 1 (cache-miss 0) > In unknown file: > 0 (scm-error goops-error #f "No applicable method for ~S in c= all ~S" (#< =E2=80=A6) =E2=80=A6) > > Apparently the problem is that =E2=80=98zero?=E2=80=99 is defined in two = modules and > the vector2 definition overrides it. This isn=E2=80=99t the case with oth= er > primitives like =E2=80=98+=E2=80=99 or =E2=80=98*=E2=80=99, so this seems= like a bug? I had built > Guile from HEAD a few days ago, my package manager shows 6fff84d as > the version number, so I guess that must be the hash of the commit > HEAD was pointing to at that time. Actually the (vector2) module makes a fresh definition for zero?. You can tell because zero? is in its export list. So instead of extending the primitive-generic that is zero?, you are making a new definition. See: scheme@(guile-user)> (define-module (foo) #:export (zero?)) $1 =3D # scheme@(foo)> (zero? 0) :4:0: :4:0: Unbound variable: zero? Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue. If you want to extend a primitive-generic, then do that by not exporting zero?. In a way it's like mutating the primitive in place, giving it additional powers. Andy ------------=_1492614782-10630-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 8 Mar 2017 16:09:56 +0000 Received: from localhost ([127.0.0.1]:46504 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cleA0-0004uL-5b for submit@debbugs.gnu.org; Wed, 08 Mar 2017 11:09:56 -0500 Received: from eggs.gnu.org ([208.118.235.92]:50266) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1clZSR-0002Sb-Mg for submit@debbugs.gnu.org; Wed, 08 Mar 2017 06:08:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1clZSL-0007XF-J2 for submit@debbugs.gnu.org; Wed, 08 Mar 2017 06:08:34 -0500 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,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:33518) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1clZSL-0007XB-G1 for submit@debbugs.gnu.org; Wed, 08 Mar 2017 06:08:33 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41226) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1clZSK-0006xH-DZ for bug-guile@gnu.org; Wed, 08 Mar 2017 06:08:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1clZSF-0007Vr-JN for bug-guile@gnu.org; Wed, 08 Mar 2017 06:08:32 -0500 Received: from lb1.openmailbox.org ([5.79.108.160]:59792 helo=mail.openmailbox.org) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1clZSF-0007Up-Ab for bug-guile@gnu.org; Wed, 08 Mar 2017 06:08:27 -0500 Received: by mail.openmailbox.org (Postfix, from userid 20002) id 35B7251626F; Wed, 8 Mar 2017 12:07:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=openmailbox.org; s=openmailbox; t=1488971293; bh=hRnSclLA2XPDKOPKgaNwa/0x0//AH0vjQ193WV8Nhpg=; h=From:Subject:Date:To:From; b=t2t360ezEWwpxDuG+Qwxu/EO9y/KzQFLXeWbKEDjR2gsv0uxnanNXDNrGQqI5GoOc lYFcbcqMj/F0MGH/4HlAw9BhdGwfgT1rIUczcE5Kj7GdaaS5iDlLBOEMXXSj7S9DFL f2yYxu5i186CeACbK3lGfyMT1+UKXefqdBL03VWs= From: Alejandro Sanchez DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=openmailbox.org; s=openmailbox; t=1488971279; bh=hRnSclLA2XPDKOPKgaNwa/0x0//AH0vjQ193WV8Nhpg=; h=From:Subject:Date:To:From; b=FJ0MvSi3UtUxsv5cqYlc3UKDPNOEpDB6FPoRHhVkB4Uw1DJb3w/zv3mbDpsp9oBps JkovNbhmNvAiYLqi/6kduO34BEycz31vF+HYccAy8gs0IM+IAQRjUER/p4NSz6P6VW TqzdI99x1Yr/byZHzfynCTnMde/WUu9UraUL2aUE= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Defining a method named zero? breaks primitive zero? Message-Id: Date: Wed, 8 Mar 2017 12:07:56 +0100 To: bug-guile@gnu.org Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) X-Mailer: Apple Mail (2.3124) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Wed, 08 Mar 2017 11:09:55 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) If I define a =E2=80=98zero?=E2=80=99 predicate method for a custom = class the primitive =E2=80=98zero?=E2=80=99 is lost. Here is a simple = vector module: ;;; File vector2.scm (define-module (vector2) #:use-module (oop goops) #:export ( get-x get-y zero?)) =09 (define-class () (x #:init-value 0 #:getter get-x #:init-keyword #:x) (y #:init-value 0 #:getter get-y #:init-keyword #:y) ) (define-generic zero?) (define-method (zero? (v )) (and (zero? (get-x v)) (zero? (get-y v)))) In the Guile REPL try executing the following code: scheme@(guile-user)> (use-modules (oop goops) (vector2)) scheme@(guile-user)> (zero? (make )) This will display=20 WARNING: (guile-user): `zero?' imported from both (ice-9 r5rs) = and (vector2) ERROR: In procedure scm-error: ERROR: No applicable method for #< zero? (1)> in call = (zero? 0) =09 Entering a new prompt. Type `,bt' for a backtrace or `,q' to = continue. scheme@(guile-user) [1]> ,bt In vector2.scm: 11:7 2 (_ #< 105e87e00>) In oop/goops.scm: 1438:4 1 (cache-miss 0) In unknown file: 0 (scm-error goops-error #f "No applicable method for = ~S in call ~S" (#< =E2=80=A6) =E2=80=A6) Apparently the problem is that =E2=80=98zero?=E2=80=99 is defined in two = modules and the vector2 definition overrides it. This isn=E2=80=99t the = case with other primitives like =E2=80=98+=E2=80=99 or =E2=80=98*=E2=80=99= , so this seems like a bug? I had built Guile from HEAD a few days ago, = my package manager shows 6fff84d as the version number, so I guess that = must be the hash of the commit HEAD was pointing to at that time.= ------------=_1492614782-10630-1-- From unknown Sat Aug 16 16:21:30 2025 X-Loop: help-debbugs@gnu.org Subject: bug#26026: closed (Re: bug#26026: Defining a method named zero? breaks primitive zero?) Resent-From: Alejandro Sanchez Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Sat, 22 Apr 2017 14:47:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 26026 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: 26026@debbugs.gnu.org Received: via spool by 26026-submit@debbugs.gnu.org id=B26026.149287240822287 (code B ref 26026); Sat, 22 Apr 2017 14:47:01 +0000 Received: (at 26026) by debbugs.gnu.org; 22 Apr 2017 14:46:48 +0000 Received: from localhost ([127.0.0.1]:34559 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d1wJE-0005nP-4M for submit@debbugs.gnu.org; Sat, 22 Apr 2017 10:46:48 -0400 Received: from lb1.openmailbox.org ([5.79.108.160]:39065 helo=mail.openmailbox.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d1wJB-0005nG-OL for 26026@debbugs.gnu.org; Sat, 22 Apr 2017 10:46:46 -0400 Received: by mail.openmailbox.org (Postfix, from userid 20002) id AFC95509AA9; Sat, 22 Apr 2017 16:46:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=openmailbox.org; s=openmailbox; t=1492872404; bh=VD+ZqvLMRXqEJX7D+2oDwFlBNSnIWXSjVDoSC16ixLY=; h=From:Subject:Date:References:To:In-Reply-To:From; b=BM0/61FCwdKpGmEgPq+fHje2dV+JEL+BwbUXjYIelo6hxBt20lfVZVSOUHc8J+1eL kPEHTmklh+CttN8ylYME1i+TfCfu8We3Bck6C4YviPFlP0L3LkbZwPVoh3uwn9M+qr k9JgfMvA5OeEv/9cI2mdzKegWjJ9ODzot6KtKg+Y= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ZDZR002 X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=HTML_MESSAGE,NO_RECEIVED, NO_RELAYS,T_DKIM_INVALID,URIBL_BLOCKED autolearn=disabled version=3.4.0 From: Alejandro Sanchez DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=openmailbox.org; s=openmailbox; t=1492872403; bh=VD+ZqvLMRXqEJX7D+2oDwFlBNSnIWXSjVDoSC16ixLY=; h=From:Subject:Date:References:To:In-Reply-To:From; b=OA9590yiAVgkQY09zaEJkDXwg+QEb3KvxVaMirzdR84Cn4THTu4bCJT79CxxsdpZA TD0vUZloQpyGHfrPZH6p80rXym9OOAPQTcFNKn6KyCSLfnq+tS/YEOpiZ0kzEfg9iv vIPaAsXcfrKzHFtAaA8/kLqSQWuBqNnhApVRi6Qs= Content-Type: multipart/alternative; boundary="Apple-Mail=_A398ED73-2A41-4C37-98FD-277759D280DE" Message-Id: Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Date: Sat, 22 Apr 2017 16:46:40 +0200 References: <87mvbcl9df.fsf@igalia.com> In-Reply-To: X-Mailer: Apple Mail (2.3124) X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) --Apple-Mail=_A398ED73-2A41-4C37-98FD-277759D280DE Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 This does not work. If I remove the export of =E2=80=98zero?=E2=80=99 I = get another error: scheme@(guile-user)> (zero? (make )) :3:1: :3:1: In procedure =3D: Wrong = type: #< 106606e20> =09 Entering a new prompt. Type `,bt' for a backtrace or `,q' to = continue. scheme@(guile-user) [1]> ,bt In current input: 3:1 0 (_) scheme@(guile-user) [1]> That is why I was exporting =E2=80=98zero?=E2=80=99 to begin with. I do = not have to export =E2=80=98+=E2=80=99 or =E2=80=98-=E2=80=98 for = example. > On 19 Apr 2017, at 17:13, GNU bug Tracking System = wrote: >=20 > Your bug report >=20 > #26026: Defining a method named zero? breaks primitive zero? >=20 > which was filed against the guile package, has been closed. >=20 > The explanation is attached below, along with your original report. > If you require more details, please reply to 26026@debbugs.gnu.org. >=20 > --=20 > 26026: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D26026 > GNU Bug Tracking System > Contact help-debbugs@gnu.org with problems >=20 > From: Andy Wingo > Subject: Re: bug#26026: Defining a method named zero? breaks primitive = zero? > Date: 19 April 2017 at 17:12:12 GMT+2 > To: Alejandro Sanchez > Cc: 26026-done@debbugs.gnu.org >=20 >=20 > On Wed 08 Mar 2017 12:07, Alejandro Sanchez = writes: >=20 >> If I define a =E2=80=98zero?=E2=80=99 predicate method for a custom = class the primitive =E2=80=98zero?=E2=80=99 is lost. Here is a simple = vector module: >>=20 >> ;;; File vector2.scm >> (define-module (vector2) >> #:use-module (oop goops) >> #:export ( get-x get-y zero?)) >> =09 >> (define-class () >> (x #:init-value 0 #:getter get-x #:init-keyword #:x) >> (y #:init-value 0 #:getter get-y #:init-keyword #:y) ) >>=20 >> (define-generic zero?) >> (define-method (zero? (v )) >> (and (zero? (get-x v)) >> (zero? (get-y v)))) >>=20 >> In the Guile REPL try executing the following code: >>=20 >> scheme@(guile-user)> (use-modules (oop goops) (vector2)) >> scheme@(guile-user)> (zero? (make )) >>=20 >> This will display=20 >>=20 >> WARNING: (guile-user): `zero?' imported from both (ice-9 r5rs) = and (vector2) >> ERROR: In procedure scm-error: >> ERROR: No applicable method for #< zero? (1)> in call = (zero? 0) >> =09 >> Entering a new prompt. Type `,bt' for a backtrace or `,q' to = continue. >> scheme@(guile-user) [1]> ,bt >> In vector2.scm: >> 11:7 2 (_ #< 105e87e00>) >> In oop/goops.scm: >> 1438:4 1 (cache-miss 0) >> In unknown file: >> 0 (scm-error goops-error #f "No applicable method for = ~S in call ~S" (#< =E2=80=A6) =E2=80=A6) >>=20 >> Apparently the problem is that =E2=80=98zero?=E2=80=99 is defined in = two modules and >> the vector2 definition overrides it. This isn=E2=80=99t the case with = other >> primitives like =E2=80=98+=E2=80=99 or =E2=80=98*=E2=80=99, so this = seems like a bug? I had built >> Guile from HEAD a few days ago, my package manager shows 6fff84d as >> the version number, so I guess that must be the hash of the commit >> HEAD was pointing to at that time. >=20 > Actually the (vector2) module makes a fresh definition for zero?. You > can tell because zero? is in its export list. So instead of extending > the primitive-generic that is zero?, you are making a new definition. > See: >=20 > scheme@(guile-user)> (define-module (foo) #:export (zero?)) > $1 =3D # > scheme@(foo)> (zero? 0) > :4:0: :4:0: Unbound variable: zero? >=20 > Entering a new prompt. Type `,bt' for a backtrace or `,q' to = continue. >=20 > If you want to extend a primitive-generic, then do that by not = exporting > zero?. In a way it's like mutating the primitive in place, giving it > additional powers. >=20 > Andy >=20 >=20 >=20 >=20 > From: Alejandro Sanchez > Subject: Defining a method named zero? breaks primitive zero? > Date: 8 March 2017 at 12:07:56 GMT+1 > To: bug-guile@gnu.org >=20 >=20 > If I define a =E2=80=98zero?=E2=80=99 predicate method for a custom = class the primitive =E2=80=98zero?=E2=80=99 is lost. Here is a simple = vector module: >=20 > ;;; File vector2.scm > (define-module (vector2) > #:use-module (oop goops) > #:export ( get-x get-y zero?)) > =09 > (define-class () > (x #:init-value 0 #:getter get-x #:init-keyword #:x) > (y #:init-value 0 #:getter get-y #:init-keyword #:y) ) >=20 > (define-generic zero?) > (define-method (zero? (v )) > (and (zero? (get-x v)) > (zero? (get-y v)))) >=20 > In the Guile REPL try executing the following code: >=20 > scheme@(guile-user)> (use-modules (oop goops) (vector2)) > scheme@(guile-user)> (zero? (make )) >=20 > This will display=20 >=20 > WARNING: (guile-user): `zero?' imported from both (ice-9 r5rs) = and (vector2) > ERROR: In procedure scm-error: > ERROR: No applicable method for #< zero? (1)> in call = (zero? 0) > =09 > Entering a new prompt. Type `,bt' for a backtrace or `,q' to = continue. > scheme@(guile-user) [1]> ,bt > In vector2.scm: > 11:7 2 (_ #< 105e87e00>) > In oop/goops.scm: > 1438:4 1 (cache-miss 0) > In unknown file: > 0 (scm-error goops-error #f "No applicable method for = ~S in call ~S" (#< =E2=80=A6) =E2=80=A6) >=20 > Apparently the problem is that =E2=80=98zero?=E2=80=99 is defined in = two modules and the vector2 definition overrides it. This isn=E2=80=99t = the case with other primitives like =E2=80=98+=E2=80=99 or =E2=80=98*=E2=80= =99, so this seems like a bug? I had built Guile from HEAD a few days = ago, my package manager shows 6fff84d as the version number, so I guess = that must be the hash of the commit HEAD was pointing to at that time. >=20 >=20 >=20 --Apple-Mail=_A398ED73-2A41-4C37-98FD-277759D280DE Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 This does not work. If I remove the export of =E2=80=98zero?=E2= =80=99 I get another error:

scheme@(guile-user)> =  (zero? (make <vector2>))
= <unnamed port>:3:1: <unnamed port>:3:1: In procedure = =3D: Wrong type: #<<vector2> 106606e20>
=
Entering a new prompt.  Type = `,bt' for a backtrace or `,q' to continue.
= scheme@(guile-user) [1]> ,bt
In = current input:
      3:1  0 = (_)
scheme@(guile-user) = [1]>

That = is why I was exporting =E2=80=98zero?=E2=80=99 to begin with. I do not = have to export =E2=80=98+=E2=80=99 or =E2=80=98-=E2=80=98 for = example.

On 19 Apr 2017, at 17:13, GNU = bug Tracking System <help-debbugs@gnu.org> wrote:

Your bug report

#26026: Defining a method named zero? breaks = primitive zero?

which was filed against the = guile package, has been closed.

The = explanation is attached below, along with your original report.
If you require more details, please reply to 26026@debbugs.gnu.org.

-- =
26026: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D26026
GNU Bug Tracking System
Contact help-debbugs@gnu.org = with problems

From: Andy Wingo <wingo@igalia.com>
Subject: = Re: bug#26026: = Defining a method named zero? breaks primitive zero?
Date: 19= April 2017 at 17:12:12 GMT+2
To: = Alejandro Sanchez <hiphish@openmailbox.org>
Cc: = 26026-done@debbugs.gnu.org


On Wed 08 Mar 2017 12:07, Alejandro Sanchez = <hiphish@openmailbox.org> writes:

If I define a = =E2=80=98zero?=E2=80=99 predicate method for a custom class the = primitive =E2=80=98zero?=E2=80=99 is lost. Here is a simple vector = module:

;;; File vector2.scm
= (define-module (vector2)
=  #:use-module (oop goops)
=  #:export (<vector2> get-x get-y zero?))

= (define-class <vector2> ()
 (x = #:init-value 0 #:getter get-x #:init-keyword #:x)
 (y = #:init-value 0 #:getter get-y #:init-keyword #:y) )

= (define-generic zero?)
(define-method (zero? (v = <vector2>))
 (and (zero? (get-x v))
=       (zero? (get-y v))))

In the Guile REPL try executing the following = code:

scheme@(guile-user)> = (use-modules (oop goops) (vector2))
= scheme@(guile-user)> (zero? (make <vector2>))

This will display

= WARNING: (guile-user): `zero?' imported from both (ice-9 r5rs) = and (vector2)
ERROR: In procedure scm-error:
= ERROR: No applicable method for #<<generic> zero? = (1)> in call (zero? 0)

Entering = a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
= scheme@(guile-user) [1]> ,bt
In = vector2.scm:
    11:7 =  2 (_ #<<vector2> 105e87e00>)
In = oop/goops.scm:
  1438:4  1 = (cache-miss 0)
In unknown file:
=           0 = (scm-error goops-error #f "No applicable method for ~S in call ~S" = (#<<gen=E2=80=A6> =E2=80=A6) =E2=80=A6)

Apparently the problem is that =E2=80=98zero?=E2=80=99 is = defined in two modules and
the vector2 definition = overrides it. This isn=E2=80=99t the case with other
primitives like =E2=80=98+=E2=80=99 or =E2=80=98*=E2=80=99, = so this seems like a bug? I had built
Guile from HEAD a = few days ago, my package manager shows 6fff84d as
the = version number, so I guess that must be the hash of the commit
HEAD was pointing to at that time.

Actually the (vector2) module = makes a fresh definition for zero?.  You
can tell = because zero? is in its export list.  So instead of extending
the primitive-generic that is zero?, you are making a new = definition.
See:

=  scheme@(guile-user)> (define-module (foo) #:export (zero?))
 $1 =3D #<directory (foo) 1203c80>
=  scheme@(foo)> (zero? 0)
 <unnamed = port>:4:0: <unnamed port>:4:0: Unbound variable: zero?

 Entering a new prompt.  Type `,bt' = for a backtrace or `,q' to continue.

If you = want to extend a primitive-generic, then do that by not exporting
zero?.  In a way it's like mutating the primitive in = place, giving it
additional powers.

Andy




From: Alejandro Sanchez <hiphish@openmailbox.org>
Subject: = Defining a method = named zero? breaks primitive zero?
Date: = 8 March 2017 at 12:07:56 = GMT+1


If I define a = =E2=80=98zero?=E2=80=99 predicate method for a custom class the = primitive =E2=80=98zero?=E2=80=99 is lost. Here is a simple vector = module:

;;; File vector2.scm
= (define-module (vector2)
=  #:use-module (oop goops)
=  #:export (<vector2> get-x get-y zero?))

= (define-class <vector2> ()
 (x = #:init-value 0 #:getter get-x #:init-keyword #:x)
 (y = #:init-value 0 #:getter get-y #:init-keyword #:y) )

= (define-generic zero?)
(define-method (zero? (v = <vector2>))
 (and (zero? (get-x v))
=       (zero? (get-y v))))

In the Guile REPL try executing the following = code:

scheme@(guile-user)> = (use-modules (oop goops) (vector2))
= scheme@(guile-user)> (zero? (make <vector2>))

This will display

= WARNING: (guile-user): `zero?' imported from both (ice-9 r5rs) = and (vector2)
ERROR: In procedure scm-error:
= ERROR: No applicable method for #<<generic> zero? = (1)> in call (zero? 0)

Entering = a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
= scheme@(guile-user) [1]> ,bt
In = vector2.scm:
    11:7 =  2 (_ #<<vector2> 105e87e00>)
In = oop/goops.scm:
  1438:4  1 = (cache-miss 0)
In unknown file:
=           0 = (scm-error goops-error #f "No applicable method for ~S in call ~S" = (#<<gen=E2=80=A6> =E2=80=A6) =E2=80=A6)

Apparently the problem is that =E2=80=98zero?=E2=80=99 is = defined in two modules and the vector2 definition overrides it. This = isn=E2=80=99t the case with other primitives like =E2=80=98+=E2=80=99 or = =E2=80=98*=E2=80=99, so this seems like a bug? I had built Guile from = HEAD a few days ago, my package manager shows 6fff84d as the version = number, so I guess that must be the hash of the commit HEAD was pointing = to at that time.




= --Apple-Mail=_A398ED73-2A41-4C37-98FD-277759D280DE--