]> gitweb.factorcode.org Git - factor.git/commitdiff
Add 'bind-in' vocabulary (the -> operator...)
authorEduardo Cavazos <dharmatech@finkelstein.stackeffects.info>
Wed, 15 Oct 2008 09:44:18 +0000 (04:44 -0500)
committerEduardo Cavazos <dharmatech@finkelstein.stackeffects.info>
Wed, 15 Oct 2008 09:44:18 +0000 (04:44 -0500)
extra/bind-in/bind-in.factor [new file with mode: 0644]
extra/dns/cache/nx/nx.factor [new file with mode: 0644]

diff --git a/extra/bind-in/bind-in.factor b/extra/bind-in/bind-in.factor
new file mode 100644 (file)
index 0000000..ab6ff19
--- /dev/null
@@ -0,0 +1,12 @@
+
+USING: kernel parser lexer locals.private ;
+
+IN: bind-in
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: ->
+  "[" parse-tokens make-locals dup push-locals
+  \ ] (parse-lambda) <lambda>
+  parsed-lambda
+  \ call parsed ; parsing
\ No newline at end of file
diff --git a/extra/dns/cache/nx/nx.factor b/extra/dns/cache/nx/nx.factor
new file mode 100644 (file)
index 0000000..9904f85
--- /dev/null
@@ -0,0 +1,35 @@
+
+USING: kernel assocs locals combinators
+       math math.functions system unicode.case ;
+
+IN: dns.cache.nx
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: nx-cache ( -- table ) H{ } ;
+
+: nx-cache-at        (      name -- time ) >lower nx-cache at        ;
+: nx-cache-delete-at (      name --      ) >lower nx-cache delete-at ;
+: nx-cache-set-at    ( time name --      ) >lower nx-cache set-at    ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: now ( -- seconds ) millis 1000.0 / round >integer ;
+
+:: non-existent-name? ( NAME -- ? )
+   [let | TIME [ NAME nx-cache-at ] |
+     {
+       { [ TIME f    = ] [                         f ] }
+       { [ TIME now <= ] [ NAME nx-cache-delete-at f ] }
+       { [ t           ] [                         t ] }
+     }
+     cond
+   ] ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+:: cache-non-existent-name ( NAME TTL -- )
+   [let | TIME [ TTL now + ] | TIME NAME nx-cache-set-at ] ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+