cakeml icon indicating copy to clipboard operation
cakeml copied to clipboard

Add join points to compiler.

Open ordinarymath opened this issue 8 months ago • 0 comments

Compilers like Haskell support the notion of join points. Join points are continuations. See examples like this

fun x = 
let y () = z
 in  ... y()

where the closure compiles to a jump instruction. This is useful in reducing duplicated code size in pattern matches i.e.

(case x of
(x::x::y) | a 
[x] | a
_ | b
-->
let A () = a
(case x of
(x::x::y) | A ()
[x] | A()
_ | b

This issue is just about making manually written join points written at source to compile to jump instructions. Note that given that cakeml is direct style one would want to inline join points used once. Another issue can be created for making the pmatch compiler generate join points. Note that this issue is not talking about supporting haskell style recursive join points.

ordinarymath avatar Apr 27 '25 15:04 ordinarymath