Welcome to the CHICKEN Scheme pasting service

coops bug? pasted by megane on Wed Jun 13 17:32:38 2012

(require-extension coops)

(define-class <a> ())

(define (foo a)
  (values 1 2))

(define-method (bar (a <a>))
  (values 1 2))

(receive (i j) (foo (make <a>))
	 (print i j))

(receive (i j) (bar (make <a>))
	 (print i j))

;; Output both compiled and interpreted:
;; 12

;; Error: bad argument count - received 1 but expected 2: #<procedure (? i j)>

fix? added by megane on Wed Jun 13 18:30:08 2012

Index: coops.scm
===================================================================
--- coops.scm	(revision 26776)
+++ coops.scm	(working copy)
@@ -372,21 +372,23 @@
 				 (lambda (%before-method)
 				   (apply %before-method %args))
 				 %applicable-before-methods)
-				(let ((%res
+				(call-with-values
+				     (lambda ()
 				       (apply
 					(let
 					    ((m (car %applicable-primary-methods)))
 					  (set! %applicable-primary-methods
-					    (cdr %applicable-primary-methods))
+						(cdr %applicable-primary-methods))
 					  m)
 					%next-method?
 					%call-next-method
-					%args)))
-				  (for-each
-				   (lambda (%after-method)
-				     (apply %after-method %args))
-				   %applicable-after-methods)
-				  %res))))))
+					%args))
+				   (lambda (#!rest %res)
+				     (for-each
+				      (lambda (%after-method)
+					(apply %after-method %args))
+				      %applicable-after-methods)
+				     (apply values %res))))))))
 		   (%call-next-method))))))
 	 (cond-expand
 	   (no-cache

Your annotation:

Enter a new annotation:

Your nick:
The title of your paste:
Your paste (mandatory) :
What is the operator to construct pairs?
Visually impaired? Let me spell it for you (wav file) download WAV