[functional-tests] fluid-let
This commit is contained in:
parent
2fe464a4cf
commit
bc765ce89d
@ -2,7 +2,8 @@
|
|||||||
(utils)
|
(utils)
|
||||||
(export inc!
|
(export inc!
|
||||||
dec!
|
dec!
|
||||||
swap!)
|
swap!
|
||||||
|
fluid-let)
|
||||||
(import (rnrs))
|
(import (rnrs))
|
||||||
|
|
||||||
(define-syntax inc!
|
(define-syntax inc!
|
||||||
@ -21,4 +22,16 @@
|
|||||||
(let ((tmp x))
|
(let ((tmp x))
|
||||||
(set! x y)
|
(set! x y)
|
||||||
(set! y tmp)))))
|
(set! y tmp)))))
|
||||||
|
|
||||||
|
(define-syntax fluid-let
|
||||||
|
(syntax-rules ()
|
||||||
|
((_ ((x e)) b1 b2 ...)
|
||||||
|
(let ((y e))
|
||||||
|
(let ((swap (lambda ()
|
||||||
|
(let ((t x))
|
||||||
|
(set! x y)
|
||||||
|
(set! y t)))))
|
||||||
|
(dynamic-wind swap (lambda ()
|
||||||
|
b1 b2 ...)
|
||||||
|
swap))))))
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user