Henry wrote: > Can we come down from the lofty heights of theory to give a practical > example of how TCO would work in J? I'm having trouble seeing it.
The short answer is, the advantage does not lie in any particular verb. As you noticed, it's easy to optimize a given verb by rewriting it. The advantage lies in *all* tail recursive verbs, in the ability to express these and depend on them, without having to go through the superfluous exercise of rewriting them every time. TCO is just another extension of J's philosophy, that lets the programmer focus on expressing the problem, and the interpreter focus on solving it. Take your quicksort for example. We do not need it because J has /:~ . But if J didn't have /:~ and I lobbied for its inclusion, would you respond to me that "the interpreter can never know the ideal sort to use for an arbitrary list, and it's easy enough for the programmer to select and implement quicksort, mergesort, etc, as necessary"? I don't want to think about which sort to use. I do not want to implement sorts, even if they're well established in the industry and easy to implement. I do not want to select among sorts. I just want to tell the interpreter "sort this", and have it do so, and do so quickly in a significant number of cases. Does that make sense? -Dan ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
