6 ms·
I do use it directly. For example in Fexl I define the append function for lists as: \append=(@\append\x\y x y \h\t [h; append t y]) Where '@' is the Y-c
by fexl 12y ago
I do use it directly. For example in Fexl I define the append function for lists as:
\append=(@\append\x\y x y \h\t [h; append t y])
Where '@' is the Y-combinator.
Note that there's no direct self-reference with the symbol "append" there. I could define it equivalently as:
\append=(@\loop\x\y x y \h\t [h; loop t y])
- anatoly 12y agoWhy? Is it unreasonably difficult for you to implement recursion via direct self-reference in your language? Or do you just not want to because the Y combinator is there and it's cool?
- fexl 12y agoTrue, I could implement it in terms of direct self-reference. At one point I used the "==" syntax for just that purpose: \append==(\x\y x y \h\t [h; append t y]) Maybe I should resurrect that syntax option. :) It was trivial to implement. When the parser sees the "==", it just automatically abstracts the symbol "append" from the definition and applies the fixpoint operator (Y combinator). The only reason I eliminated "==" in the first place was that I was in the throes of using different syntaxes for lazy, eager, and self-referencing definitions. Now I've settled in on "=" always meaning eager evaluation, without exception. Then I got hyper-minimalist and said that's it, there's only one syntax for definitions, and it's "=", and if you want self-reference, use "@". However, the decision to settle in on eager evaluation now frees up "==" once again as an option for self-reference. So I may bring that back. Thanks for the food for thought.
- fexl 12y agoPostscript: You might well ask why not just use "=" only, and assume that all definitions are potentially self-referencing? That's a non-starter because I find that redefinition is the more common intent: \x=4 \x=(* x 5) \x=(+ y x) In those cases I don't want x defined in terms of itself, but rather in terms of the previous definition of x. That is why I would insist on a special token such as "==" to express the intention of self-reference.
- fexl 12y agoOK, I went ahead and revived the "==" syntax for recursive definitions, so you don't have to use '@' (fixpoint) explicitly. https://github.com/chkoreff/Fexl/commit/57b841cb6c2347cad1473ccf34040a1a007b9e97 https://github.com/chkoreff/Fexl/commit/57b841cb6c2347cad147...