Tail recursion is a strategy for optimization.
If a language already has recursion then tail 
recursion does not add to its expressiveness. 
Currently J does not exploit tail recursion.
If/when appropriate the strategy can be 
implemented.  It'd be another implementation
trick like those already in Appendix B (Special
Code) of the dictionary.

I believe M. (memo) offers greater benefits
for recursive functions than tail recursion.

I don't see much advantage to thinking of f^:n
as a recursion.  It is not implemented as 
a recursion (does not use the call stack),
and it's not defined recursively.

What is function-level iteration?



----- Original Message -----
From: Tracy Harms <[email protected]>
Date: Wednesday, May 13, 2009 14:48
Subject: [Jprogramming] tail recursion/TCO?
To: Programming forum <[email protected]>

> I may not have an accurate understanding of the relationship between
> function-level iteration in J and tail recursion. I'm particularly
> interested in Power (^:) but several other primaries may apply, most
> obviously Self.
> 
> Up to now I've thought that tail recursion is not applicable to J.
> Thus in a discussion of functional programming on Twitter I've said
> that J provides a counterexample which refutes the claim that
> tail-call optimization (TCO) is necessary and important to a
> "functional programming" computer language.
> 
> As I've studied more on the topic of TCO it occurred to me that
> perhaps J's memory-management may rightly be labeled TCO in the cases
> I have in mind. As examples, consider f1a and f1b here:
> http://www.jsoftware.com/jwiki/Essays/Fibonacci%20Sequence
> 
> My questions, then, are:
> 
> Does J sometimes involve tail recursion?
> 
> If yes, but not in all recursions, how can we differentiate?
> 
> Is ^: best thought of as non-recursive? Does such categorization 
> matter?
> Thanks,
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to