Wednesday, February 20, 2019

Unfortunate

Zero-arity combinators often lead to weird behavior and I guess should, in general, be avoided. To boil it down to one example:


[ X Y -> Y X | -> 0 ] 1 2 ==> (2 1)

But

let F = [ X Y -> Y X | -> 0 ] in F 1 2 ==> (0 1 2)

The discrepancy is unfortunate but completely correct according to the operational semantics. In the first case, a lambda expression is applied to its arguments, then reduced; in the second case, the lambda expression is reduced, then applied.

It's unfortunate but I think I'll keep it.