values2.scm 582 B

1234567891011121314151617181920212223242526
  1. (define (consume1 x)
  2. (format #t "value:~a.~%" x))
  3. (define (test1)
  4. (call-with-values
  5. (lambda () 123)
  6. consume1))
  7. (define (test2)
  8. (call-with-values
  9. (lambda () 127)
  10. (lambda (x) (format #t "value:~a.~%" x))))
  11. (test1)
  12. ;; Output: value:123.
  13. (test2)
  14. ;; Output: value:127.
  15. ;; Based on bug report 2016-02-11 from OKUMURA Yuki <mjt@cltn.org>.
  16. (define (test3 b)
  17. (if (eq? b 'NONE)
  18. (values 'NONE #f)
  19. (values 'OTHERS #f)))
  20. (call-with-values (lambda () (test3 'X))
  21. (lambda vals (format #t "split-value:~a.~%" vals)))
  22. ;; Output: split-value:(OTHERS #f).