Apparently the JVM has a label/goto
mechanism. Would it be possible to add such a capability to the Clojure language?
I suppose there are two questions which could be addressed 100% independently.
1. whether it is theoretically possible. i.e., to the JVM instructions really permit such a Clojure primitive at all. Perhaps I'm mistaken, and it is really not possible.
2. whether the core Clojure maintainers can be convinced of the merits of the request.
In general goto
is useful in machine generated code, not so much in human written code.
I have at least three use cases where I'd like to have such a mechanism.
- serialization of deterministic finite automata
- serialization of discrimination nets
- translation of Knuth style algorithms into Clojure from Art of Computer Programming.
I know that lots of people might respond with philosophical arguments about why you shouldn't use goto. I hope to avoid such a discussion here.
One possibility which seems reasonable to me would be a Clojure primitive similar to the Common Lisp prog although the ability to bind variables is not really necessary, as it could easily be implemented by the user by using let
with some macrology.