diff --git a/cyclone.scm b/cyclone.scm index 5c65a03a..c255b29b 100644 --- a/cyclone.scm +++ b/cyclone.scm @@ -134,18 +134,18 @@ (set! module-globals (cons 'call/cc module-globals)) (set! input-program (cons - ;; Experimental version of call-with-values, but this - ;; is not working yet! - ;; - ;; may want to look at: - ;; http://stackoverflow.com/questions/16674214/how-to-implement-call-with-values-to-match-the-values-example-in-r5rs + ;; Experimental version of call-with-values, + ;; seems OK in compiler but not in eval. '(define call-with-values (lambda (k producer consumer) (producer - (lambda (val) - (consumer k val))))) - ;(lambda vals - ; (apply k consumer vals))))) + (lambda (result) + (consumer k result))))) + ;; multiple args requires more than just this. + ;; may want to look at: + ;; http://stackoverflow.com/questions/16674214/how-to-implement-call-with-values-to-match-the-values-example-in-r5rs + ;; (lambda vals + ;; (apply k consumer vals))))) (cons ;; call/cc must be written in CPS form, so it is added here ;; TODO: prevents this from being optimized-out diff --git a/test.scm b/test.scm index 029f7016..7de7ba0d 100644 --- a/test.scm +++ b/test.scm @@ -20,3 +20,7 @@ (define b (vector 10 20 30 40 50)) (vector-copy! b 1 a 0 2) (write (equal? b #(10 1 2 40 50))) +(call-with-values + (lambda () (values 1 1)) + (lambda (a) (write a))) +