]> gitweb.factorcode.org Git - factor-unmaintained.git/blobdiff - closures/closures.factor
unmaintained: New home for misfit Factor vocabularies.
[factor-unmaintained.git] / closures / closures.factor
diff --git a/closures/closures.factor b/closures/closures.factor
new file mode 100644 (file)
index 0000000..faa8ec0
--- /dev/null
@@ -0,0 +1,13 @@
+USING: assocs io.pathnames fry namespaces namespaces.private kernel sequences parser hashtables ;
+IN: closures
+SYMBOL: |
+
+! Selective Binding
+: delayed-bind-with ( vars quot -- quot' ) '[ _ dup [ get ] map zip >hashtable [ _ bind ] curry ] ;
+SYNTAX: C[ | parse-until parse-quotation delayed-bind-with append! ;
+! Common ones
+SYNTAX: DIR[ parse-quotation { current-directory } swap delayed-bind-with append! ;
+
+! Namespace Binding
+: bind-to-namespace ( quot -- quot' ) '[ namespace [ _ bind ] curry ] ;
+SYNTAX: NS[ parse-quotation bind-to-namespace append! ;