- Endpoints are declared by adding an
:entrypointmetadata at the function declaration, which could further extended to adefentrypointmacro. - Due to the typed nature of Michelson, the code must be typed to properly be translated to code:
- Type declarations should use the
typefunction (or macro?) to declare types for namespace defined variables. - Extra type annotation could be done by using metadata.
- Need for a type checker, which I don't know how to implement (I don't know to how to build a backend also, but don't tell anyone).
- Michelson types need a correspondence for Clojure literals, while some are possible, conjunction and disjunction types are not available for Clojure.
- Type declarations should use the
- Some types have an extra challenge, like option and or, because Clojure doesn't have the proper idioms to deal with it, I should define a few patterns to describe how to interpret them, mainly option.
- To descrease the overhead for type inference, some literals are going to be used for naturals and mutez, like
1nand1mutez.
Just like domain specific stuff are exposed on the Tezos module for LIGO, I'm going to expose those on the tezos namespace.
- Macros
- Emulate some of the dynamic features of Clojure and other Lisps
(type storage nat)
(type return (pair (list operation) storage))
(type increment (-> unit storage return))
(defn ^:entrypoint increment
[_ storage]
(tezos/pair :unit (inc storage))
(type decrement (-> unit storage return))
(defn ^:entrypoint decrement
[_ storage]
(tezos/pair :unit (dec storage)))
(type decrement (-> unit storage return))
(defn ^:entrypoint reset
[_ _]
(tezos/pair :unit 0))

Emitter state
I can't sanely have pure functions emitting code, so I'll have to have some state. Could have a better code also, using a IR using vectors and keywords as representations. It could help generating the necessary indentation later. It's important also to keep monitoring the stack size, after evaluating the whole expression, depending on the expression type the stack should have a specific size or be modified by some number, type derivations also depend on the stack.