IntersectMBO / plutus

The Plutus language implementation and tools
Apache License 2.0
1.57k stars 479 forks source link

Add `fix` to the AST #6577

Open effectfully opened 1 month ago

effectfully commented 1 month ago

Currently we use the Z combinator for singly recursive functions and this for mutually recursive functions, but this is really inefficient. Adding fix to the AST to handle at least singly recursive functions should improve performance substantially. But what about mutual recursion?

  1. Do we add PIR-style letrec that can handle both singly recursive and mutually recursive functions? This would significantly complicate the AST.
  2. Do we just give up on supporting efficient mutual recursion and tell people to encode it using single recursion like this?
  3. Do we add fixBy as an AST node as well? Or, given the above point, do we even need fixBy at all?

I think I personally prefer the second option.