GNU bug report logs -
#26106
Defining a method named '-' with one parameter
Previous Next
Full log
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
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…>)) #)
This bug report was last modified 8 years and 57 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.