module1.scm 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. (module-static #f)
  2. (module-export my-factorial list-length-2 deldup call-to-first
  3. date mod1-v5 <simpleAux>
  4. counter counter-macro
  5. test1-import0 mod0-v1 mod0-v2 mod0-v3 mod0-f1 mod0-m1
  6. namespace-syntax-test make-array make-array-fun mA)
  7. (require <module0>)
  8. (define (get1-mod0-v1) mod0-v1)
  9. (define (set1-mod0-v1 x) (set! mod0-v1 x))
  10. (define mod1-v5 15)
  11. (define (test1-import0)
  12. (let ((gv1 (get1-mod0-v1)))
  13. (set1-mod0-v1 (+ 14 gv1))
  14. (list gv1 mod0-v1 mod0-v2 (mod0-f1))))
  15. (define (my-factorial n)
  16. (if (<= n 1)
  17. 1
  18. (* n (my-factorial (- n 1)))))
  19. (define (list-length-1 (x :: <list>)) :: <double>
  20. (length x))
  21. (define (list-length-2 x) :: <int>
  22. (include-relative "included-1.scm")
  23. (inexact->exact z2))
  24. (require 'list-lib)
  25. (define-syntax deldup
  26. (syntax-rules ()
  27. ((deldup list)
  28. (delete-duplicates list))))
  29. (define (call-to-first x)
  30. (first x))
  31. (define-namespace date "class:java.util.Date")
  32. (define-syntax namespace-syntax-test
  33. (syntax-rules ()
  34. ((namespace-syntax-test)
  35. (date:parse "6 Sep 2003 UTC"))))
  36. ;; Test for Savannah bug #11508 submitted by Thomas Kirk <tk@research.att.com>:
  37. (define-syntax make-array
  38. (syntax-rules ()
  39. ((make-array len type)
  40. ((primitive-array-new type) len))
  41. ((make-array len)
  42. ((primitive-array-new <java.lang.Object>) len))))
  43. (define (make-array-fun n)
  44. (make-array n))
  45. ;; From Savannah bug#11822, contributed by Dean Ferreyra.
  46. ;; (Other parts of this testcase are in module3.scm and obj-test.scm.)
  47. (define-simple-class <simpleAux> ()
  48. (x 5)
  49. ((init) (set! x 100)))
  50. (define-syntax mA
  51. (syntax-rules ()
  52. ((_ type forms ...)
  53. (define-simple-class type ()
  54. forms ...))))
  55. ;; Andre van Tonder <andre@het.brown.edu> example in posting 2011-04-19.
  56. (define counter (let ((n 0)) (lambda () (set! n (+ n 1)) n)))
  57. (define-syntax counter-macro (syntax-rules () ((_) (counter))))