Skip to content

Instantly share code, notes, and snippets.

@zeptometer
Created March 21, 2014 19:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeptometer/9694244 to your computer and use it in GitHub Desktop.
Save zeptometer/9694244 to your computer and use it in GitHub Desktop.
(define-syntax let-values
(syntax-rules ()
((let-values (binding ...) body0 body1 ...)
(let-values "bind"
(binding ...) () (begin body0 body1 ...)))
((let-values "bind" () tmps body)
(let tmps body))
((let-values "bind" ((b0 e0)
binding ...) tmps body)
(let-values "mktmp" b0 e0 ()
(binding ...) tmps body))
((let-values "mktmp" () e0 args
bindings tmps body)
(call-with-values
(lambda () e0)
(lambda args
(let-values "bind"
bindings tmps body))))
((let-values "mktmp" (a . b) e0 (arg ...)
bindings (tmp ...) body)
(let-values "mktmp" b e0 (arg ... x)
bindings (tmp ... (a x)) body))
((let-values "mktmp" a e0 (arg ...)
bindings (tmp ...) body)
(call-with-values
(lambda () e0)
(lambda (arg ... . x)
(let-values "bind"
bindings (tmp ... (a x)) body))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment