Mailing List Archive


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

Re: [tlug] "Go Considered Harmful"



Curt J. Sampson writes:

 > how to convert non-tail-call recursive functions into tail call
 > form[?]  It's not difficult to do, ... but is it really essential
 > complexity? Or is dealing with that something that the language
 > system should do?

Of course it depends.  Language implementers need to know how to do
that.  Application implementers would be fine with "recursive calls
are optimized and compiled efficiently enough that you should rarely
if ever need to convert them to another form".  But it's not obvious
to me that that's true.

 > But still, aside from that, at least anybody can look at simple recursive
 > functions even in a language they don't know and understand exactly the
 > iteration conditions.

Sure.  And people do arithmetic with the Peano postulates too! ... wait.

Note that "simple" is carrying a heavy load here.  In a language with
side effects recursion suffers from the I = PLAY(0) problem.  

 > I happened to be reformatting some BASIC code the other day (don't
 > ask) and realized that it's not obvious how FOR loops really work.

So BASIC sucks.  Python (for one, I pick Python because I know it
well) doesn't have that problem.  (Of course it has the I = PLAY(0)
problem.)

Here's an hypothesis for you: Humans need ambiguity and therefore
prefer 'for'. ;-)

More seriously, I think that at least in the old days iteration made
it easy to estimate big O complexity.  You have to think a lot harder
with multiply recursive functions or mutual recursive sets of
functions.  I'm not sure whether that's important to newbies.

Steve


Home | Main Index | Thread Index