[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: why tail recursion matters and why Java isn't it, was Re: lisp performance was Re: problems with lisp

On Thursday, September 4, 2003, at 02:31 PM, Avi Bryant wrote:

> On Thu, 4 Sep 2003, Michael Sperber wrote:
>> The real issue with LOOP and most other looping constructs is (as
>> Matthias pointed out), that "looping" almost always is about the
>> structure of the data, namely about the structure of self-referential
>> data.  Recursive programs simply reflect that fact by having a
>> recursive call on the self-reference---it's a clear and
>> straightforward way of writing such programs.  "Loop constructs"
>> generally obscure that issue.
> That makes lots of sense for lists.  In many languages, however, the
> vector is a much more prominent data structure, and I don't see the 
> self
> reference there.
> Would you argue that an iteration through a vector is in fact an 
> iteration
> through its indices, and that the self reference is Integer->Integer?
> Or would you concede that a loop (of the for(int i = 0; i < x; i++)
> variety, although hopefully abstracted further than that) is a more
> "straightforward" way of dealing with vector data?
> I have no particular opinion either way, I'm just curious.

1. It is easy to define N via self-reference ( N = 0 u add1(N) ). So it 
the carrier of the vector that is defined via self-reference.

2. I still insist that the only proper way to address this from ground 
is to say "send a loop message to an object of type Array."  Follow this
through logically and you will arrive at
and things like that. It gives you an object back and then you compute
with it.

For heaven's sake, that's how Guy and Gerry figured out Scheme in the
first place.

-- Matthias