A peer-to-peer stack for code collaboration
(def sas-password "very secret")
(def sas-store (ref (dict)))
(def sas-eval-ref (ref eval))
;; self-amending key-val store
(def sas-starting-eval
(fn [expr]
(def command (head expr))
(cond
(eq? command 'get) (lookup (nth 1 expr) (read-ref sas-store))
(eq? command 'set) (modify-ref sas-store (fn [s] (insert (nth 1 expr) (nth 2 expr) s)))
(and (eq? command 'update)
(eq? (nth 1 expr)
sas-password))
(write-ref sas-eval-ref (eval (nth 2 expr)))
:else (throw 'invalid-command "Valid commands are: 'get', 'set' and 'update'."))))