From: Alejandro Sanchez <hiphish@openmailbox.org>
To: 26106@debbugs.gnu.org
Subject: bug#26106: Defining a method named '-' with one parameter
Date: Wed, 15 Mar 2017 14:35:18 +0100 [thread overview]
Message-ID: <F7542921-8F39-4B4E-B8ED-B6E8F53DAD10@openmailbox.org> (raw)
If I define a method named ‘-‘ which only takes in one parameter, the expression ‘(- v)’ gets rewritten to ‘(- 0 v)’. Here is a minimal example:
(use-modules (oop goops))
(define-class <vector2> ()
(x #:init-value 0 #:getter get-x #:init-keyword #:x)
(y #:init-value 0 #:getter get-y #:init-keyword #:y))
(define-method (* (n <number>) (v <vector2>))
(make <vector2> #:x (* n (get-x v)) #:y (* n (get-y v))))
(define-method (- (v <vector2>))
(* -1 v))
(define v (make <vector2> #:x 1 #:y 2))
(* -1 v) ; Works fine
(- v) ; Throws error
Here is the error message:
scheme@(guile-user)> (- v)
ERROR: In procedure scm-error:
ERROR: No applicable method for #<<generic> - (2)> in call (- 0 #<<vector2> 10a8e4020>)
Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue.
scheme@(guile-user) [1]> ,bt
In current input:
23:0 2 (_)
In oop/goops.scm:
1438:4 1 (cache-miss 0 #<<vector2> 10a8e4020>)
In unknown file:
0 (scm-error goops-error #f "No applicable method for ~S in call ~S" (#<<generic> - (2)> (- 0 #<<vec…>)) #)
next reply other threads:[~2017-03-15 13:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-15 13:35 Alejandro Sanchez [this message]
2017-04-19 15:00 ` bug#26106: Defining a method named '-' with one parameter Andy Wingo
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=F7542921-8F39-4B4E-B8ED-B6E8F53DAD10@openmailbox.org \
--to=hiphish@openmailbox.org \
--cc=26106@debbugs.gnu.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).