Re:What is “Open Recursion”?
by Sean1708 on Wednesday July 19, 2017 @09:42AM
(#14804192)
Do you mean like this?
Obviously that's a completely useless and convoluted example, but I'm fairly sure the concept of a lambda calling the function it was passed to just works in most languages.
[ Parent
| on HN ]
it was a stupid joke about the y combinator. you can arrange a version with more function arguments that'll call all of the parts with their lambda friends. so they can all call each other.
so something vaguely like
(define local-state)
(super-y
(lambda (inc get set v)
(set inc get set (+ 1(get inc get set v))))) ;this one is inc
(lambda (inc get set v) local-state) ;this one is get
(lambda (inc get set v) (set! local-state v)) ; this one is set
you don't really even need local state, just pass around an accumulator.Once you have lambdas and a system that allows infinite types, mutual visibility is pretty easy to come by, mutual anonymous recursion is something i think is super nifty.
you can save yourself some pain by sticking the functions in a map, of course and passing that around instead.