3 ms·
Creating a new function for every tail call seems a bit awful. It's a shame that the more performant alternatives are ridiculously ugly.
by anonymoushn 13y ago
Creating a new function for every tail call seems a bit awful. It's a shame that the more performant alternatives are ridiculously ugly.
- badman_ting 13y agoRight, plus how is someone supposed to come in, look at the resulting code, and figure out how it works? Functions wrapped in functions wrapped in functions. (Remember, this is supposed to be the "ridiculously simple" case.) On the other hand, we do a lot of wrapping things in functions in JS-land, so this probably says more about the state of the art than anything.
- justincormack 13y agoA trampolined state machine reads OK, where each state is the next transition function. But generally, you want tail recursion...
- darkstalker 13y agoI wonder why JS doesn't implement tail calls. Lot of effort has has been made optimizing JS engines, but not for this case.