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

Re: following up on speed



>>>>> "Shriram" == Shriram Krishnamurthi <sk@cs.brown.edu> writes:

Shriram> Bruce Lewis wrote:

>> IMO converting non-tail recursion to tail recursion was taught too early
>> when I took SICP, and I suspect it still usually is.  

Shriram> Only if you use SICP to teach this material.  A book that focuses on
Shriram> program design rather than clever ways of coding solutions wouldn't
Shriram> fall into this trap.

>> non-tail recursive calls they see are supposed to be turned into tail
>> calls, they'll think "convert to tail call" every time they see a
>> non-tail call recursion after that.

Shriram> You bet!

Sigh.  I just *knew* it would come to this ...

If you have the luxury of being able to teach programming in the
context of a program design course, and the added luxury of being able
to talk about machine model, tail recursion and loops at some later
stage, sure you can avoid falling into the trap by walking around it.

Not everyone has that luxury.  If you don't, then you can also avoid
falling into it by choosing the right examples and the right homework
problems.  The lesson here is well worth learning.

-- 
Cheers =8-} Mike
Friede, Völkerverständigung und überhaupt blabla