aiken-lang / aiken

A modern smart contract platform for Cardano
https://aiken-lang.org
Apache License 2.0
474 stars 92 forks source link

Use a decision tree for when Expressions #1040

Open MicroProofs opened 1 week ago

MicroProofs commented 1 week ago

Using the algorithm from this paper https://www.cs.tufts.edu/comp/150FP/archive/luc-maranget/jun08.pdf

We can make the pattern matching when expressions in Aiken both more efficient and simpler in codegen. Instead of processing a TypedExpr of cases and nested cases. We instead build up a decision tree and use that to produce the Air op codes to carry out the pattern matching. Which enables a large simplification to the existing op codes today.

For another in depth explanation and implementation of the algorithm described above. Look here https://github.com/clojure/core.match/wiki/Understanding-the-algorithm