srfi-11.scm 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. ; Taken directly from the SRFI document.
  2. (define-syntax let-values
  3. (syntax-rules ()
  4. ((let-values (?binding ...) ?body0 ?body1 ...)
  5. (let-values "bind" (?binding ...) () (begin ?body0 ?body1 ...)))
  6. ((let-values "bind" () ?tmps ?body)
  7. (let ?tmps ?body))
  8. ((let-values "bind" ((?b0 ?e0) ?binding ...) ?tmps ?body)
  9. (let-values "mktmp" ?b0 ?e0 () (?binding ...) ?tmps ?body))
  10. ((let-values "mktmp" () ?e0 ?args ?bindings ?tmps ?body)
  11. (call-with-values
  12. (lambda () ?e0)
  13. (lambda ?args
  14. (let-values "bind" ?bindings ?tmps ?body))))
  15. ((let-values "mktmp" (?a . ?b) ?e0 (?arg ...) ?bindings (?tmp ...) ?body)
  16. (let-values "mktmp" ?b ?e0 (?arg ... x) ?bindings (?tmp ... (?a x)) ?body))
  17. ((let-values "mktmp" ?a ?e0 (?arg ...) ?bindings (?tmp ...) ?body)
  18. (call-with-values
  19. (lambda () ?e0)
  20. (lambda (?arg ... . x)
  21. (let-values "bind" ?bindings (?tmp ... (?a x)) ?body))))))
  22. (define-syntax let*-values
  23. (syntax-rules ()
  24. ((let*-values () ?body0 ?body1 ...)
  25. (begin ?body0 ?body1 ...))
  26. ((let*-values (?binding0 ?binding1 ...) ?body0 ?body1 ...)
  27. (let-values (?binding0)
  28. (let*-values (?binding1 ...) ?body0 ?body1 ...)))))