I made up the phrase "function-level iteration" in an attempt to point
to iteration that is built into primaries such as ^:  not done through
recursive techniques nor built through a conventional control-word
structure (such as for-next, do-while, and repeat-until). (The term
doesn't seem to communicate that idea well.)

Thank you for confirming what I had initially understood to be the
case, that (to date) J has not exploited tail recursion. My confidence
is bolstered that J therefore stands as disproof of the idea, common
in some circles, that in order to be a "serious" "functional" language
a programming language must implement tail recursion optimization.

If there is a term that categorizes ^: along with other non-recursive
techniques for iteration on immutable entities, I'm eager to add it to
my vocabulary. Apparently this sort of thing is scarce outside the APL
family.


On Wed, May 13, 2009 at 7:24 PM, Roger Hui <[email protected]> wrote:
> 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
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to