readme
readme, docs, etc
add a license
A port of common lisp's tagbody form to clojure. Lets you enjoy unstructured control flow.
http://www.lispworks.com/documentation/HyperSpec/Body/s_tagbod.htm
com.manigfeald/tagbody {:git/url "https://git.sr.ht/~hiredman/tagbody" :sha "2ed0f6f78c01ad0c01449cbffcf29ab0a92146d2"}
(require '[com.manigfeald.tagbody :refer [tagbody go]])
(defn incf [x v]
(var-set x (+ (var-get x) v)))
(with-local-vars
[v nil]
(tagbody
(var-set v 1)
(go point-a)
(incf v 16)
point-c
(incf v 4)
(go point-b)
(incf v 32)
point-a
(incf v 2)
(go point-c)
(incf v 64)
point-b
(incf v 8))
(var-get v))
;;=> 15
tagbody uses java.lang.Throwables to jump around. This can be problematic if you catch Throwables. Exception handlers are also single threaded, so you cannot go across threads.
The way tagbody currently runs it is limitted to 254 or so expressions in a tagbody.
Expressions are converted to closures (fns) in a way that no doubt interfers with locals clearing. This will also break things like set! on mutable deftype fields.
An expression in a tagbody can never be a tail as far as loop/recur is concerned.
Maybe I can close the tagbody tab in my browser and stop thinking about it now.