3 ms·
You don't even need that, there is a much more efficient way in a language that supports let-bindings (but not letrec): let f' = func(f, g, other_args...)
by Joker_vD 3y ago
You don't even need that, there is a much more efficient way in a language that supports let-bindings (but not letrec):
let f' = func(f, g, other_args...) {
// ...
g(f, g, whatever...);
// ...
};
let g' = func(f, g, other_args...) {
// ...
f(f, g, whatever...);
// ...
}
let f = func(other_args...) { return f'(f', g', other_args...); }
let g = func(other_args...) { return g'(f', g', other_args...); }
That's basically just closure conversion, only instead of doing it the compiler backend, you do it manually yourself.
- tshaddox 3y agoThat’s true, although I wasn’t sure if simpler approaches using let bindings like that would fall under the author’s “without passing in a function to itself.”
- Joker_vD 3y agoI understood that passage as "our let won't be letrec, so no recursion for you (unless you do some self-passing trick, of course)".