aboutsummaryrefslogtreecommitdiffstats
path: root/fluid-let.scm
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2017-02-20 00:06:40 -0800
committerBryan Newbold <bnewbold@robocracy.org>2017-02-20 00:06:40 -0800
commita69c9fb665459e2bfdbda1bf80741a0af31a7faf (patch)
treef0bc974f8805049e6b9a4e6864886298fbaa05a4 /fluid-let.scm
parent4684239efa63dc1b2c1cbe37ef7d3062029f5532 (diff)
downloadslib-a69c9fb665459e2bfdbda1bf80741a0af31a7faf.tar.gz
slib-a69c9fb665459e2bfdbda1bf80741a0af31a7faf.zip
New upstream version 3b5upstream/3b5upstream
Diffstat (limited to 'fluid-let.scm')
-rwxr-xr-xfluid-let.scm39
1 files changed, 39 insertions, 0 deletions
diff --git a/fluid-let.scm b/fluid-let.scm
new file mode 100755
index 0000000..88720d6
--- /dev/null
+++ b/fluid-let.scm
@@ -0,0 +1,39 @@
+; "fluidlet.scm", FLUID-LET for Scheme
+; Copyright (c) 1998, Radey Shouman <radey_shouman@splashtech.com>
+;
+;Permission to copy this software, to redistribute it, and to use it
+;for any purpose is granted, subject to the following restrictions and
+;understandings.
+;
+;1. Any copy made of this software must include this copyright notice
+;in full.
+;
+;2. I have made no warrantee or representation that the operation of
+;this software will be error-free, and I am under no obligation to
+;provide any services, by way of maintenance, update, or otherwise.
+;
+;3. In conjunction with products arising from the use of this
+;material, there shall be no use of my name in any advertising,
+;promotional, or sales literature without prior written consent in
+;each case.
+
+(require 'dynamic-wind)
+(require 'macro)
+
+(define-syntax fluid-let
+ (syntax-rules ()
+ ((_ ((?name ?val) ...) . ?body)
+ (fluid-let "make-temps"
+ ((?name ?val) ...) () ()
+ ((?name ?val) ...) . ?body))
+ ((_ "make-temps" (?bind1 . ?binds) ?olds ?news . ?rest)
+ (fluid-let "make-temps"
+ ?binds
+ (old-tmp . ?olds)
+ (new-tmp . ?news) . ?rest))
+ ((_ "make-temps" () (?old ...) (?new ...) ((?name ?val) ...) . ?body)
+ (let ((?new ?val) ... (?old #f) ...)
+ (dynamic-wind
+ (lambda () (set! ?old ?name) ... (set! ?name ?new) ...)
+ (lambda () . ?body)
+ (lambda () (set! ?new ?name) ... (set! ?name ?old) ...))))))