lib-tailcalls.scm 950 B

123456789101112131415161718192021222324252627282930313233
  1. ;; Kawa-options: "--full-tailcalls" %F
  2. ;;; Based on testcase from OKUMURA Yuki <mjt@cltn.org> reported 2016-02-11
  3. (define-library (minidispatch)
  4. (export make-minidispatch-obj minitype-set!)
  5. (import (scheme base) (scheme write))
  6. (begin
  7. (define (minitype-set! obj::vector slot::int value)
  8. (display (list 'SET!-CALLED: slot value))(newline)
  9. (vector-set! obj slot value))
  10. (define (baseset! obj::vector slot::int v)
  11. (minitype-set! obj slot v))
  12. (define (make-minidispatch-obj class param)
  13. (let ((obj (vector "UNINITIALIZED_x" "UNINITIALIZED_y")))
  14. (baseset! obj 0 class) ;; This gets skipped
  15. (baseset! obj 1 param)
  16. obj))
  17. ))
  18. (import (scheme base)
  19. (minidispatch))
  20. (let ((obj0 (make-minidispatch-obj (vector 'testa 'testb) "INIT12")))
  21. (write obj0)
  22. (newline))
  23. ;; Output: (SET!-CALLED: 0 #(testa testb))
  24. ;; Output: (SET!-CALLED: 1 INIT12)
  25. ;; Output: #(#(testa testb) "INIT12")