Opened 9 years ago

Closed 9 years ago

#1040 closed defect (fixed)

coops: Hygiene issue with ensure-generic-procedure

Reported by: Moritz Heidkamp Owned by: felix winkelmann
Priority: minor Milestone: someday
Component: extensions Version: 4.8.x
Keywords: coops Cc:
Estimated difficulty:

Description

This program:

(use extras coops)

(define-class <foo> ())
(define-class <bar> (<foo>))

(define-method (foo (x <foo>)) `(<foo>  ,x))

(define-syntax define-foo
  (syntax-rules ()
    ((_ class)
     (define-method (foo (x class))
       `(class ,x)))))

(define-foo <bar>)

(pp (foo (make <foo>)))
(pp (foo (make <bar>)))

results in this output:

Note: implicitly defining generic-procedure: foo

Note: implicitly defining generic-procedure: foo170

Error: (foo) no method defined for given argument classes: (#<coops standard-class `<foo>'>)

	Call history:

	<eval>	  (list198 (quote197 x171))
	<eval>	  (funcallable-generic-procedure200 (slot-value201 %gp195 (quote197 generic-procedure202)) %gp195)
	<eval>	  (slot-value201 %gp195 (quote197 generic-procedure202))
	<eval>	  (create-generic-procedure207 (quote208 (setter191 foo170)) (list209 (quote208 x171)))
	<eval>	  (list209 (quote208 x171))
	<eval>	  (funcallable-generic-procedure211 (slot-value212 %gp206 (quote208 generic-procedure213)) %gp206)
	<eval>	  (slot-value212 %gp206 (quote208 generic-procedure213))
	<eval>	  ((slot-value180 foo170 (quote181 add-new-primary-method182)) (list183 <bar>) (call-next-method-lambd......
	<eval>	  (slot-value180 foo170 (quote181 add-new-primary-method182))
	<eval>	  (list183 <bar>)
	<syntax>	  (pp (foo (make <foo>)))
	<syntax>	  (foo (make <foo>))
	<syntax>	  (make <foo>)
	<eval>	  (pp (foo (make <foo>)))
	<eval>	  (foo (make <foo>))
	<eval>	  (make <foo>)	<--

Note how the second implicit generic procedure definition mentions a renamed identifier. Indeed, using an equivalent but direct method definition like this instead:

(define-method (foo (x <bar>))
  `(<bar> ,x))

works fine. The attached patch fixes this but I'm not sure if it's the correct way to do it.

Attachments (1)

ensure-generic-procedure-fix.diff (665 bytes) - added by Moritz Heidkamp 9 years ago.

Download all attachments as: .zip

Change History (2)

Changed 9 years ago by Moritz Heidkamp

comment:1 Changed 9 years ago by felix winkelmann

Resolution: fixed
Status: newclosed

Thanks - I have added the change to coops 1.93.

Note: See TracTickets for help on using tickets.