Closed 0x0f0f0f closed 4 years ago
Note that the fibonacci and factorial functions work correctly if they are not defined as lazy
Temporarily removed lazyfun
and lazylambda
statements.
The new single argument lambda abstraction fixes this issue.
There's a problem with laziness in recursion (with laziness in recursion (with laziness in recursion (with laziness ...))).
Non-recursive lazy functions work as expected, but as soon as a
lazyfun
is declared in alet rec
statement, evaluation is stuck in an endless loop and stack overflows. After investigating a bit (trying factorial and fibonacci functions) I've found out that the problem occurs when arguments are passed to the recursive application. It seems thatLazyExpression
s passed as recursive application arguments never get evaluated.https://github.com/0x0f0f0f/minicaml/blob/cfc0537dd8982b6696ba029181ebae956fdeb179/lib/eval.ml#L113-L134
Here's the example I've tried
Here's the factorial example