Software bugs aren't inevitable
hancock at anansispaceworks.com
Thu Sep 15 01:01:27 CEST 2005
On Wednesday 14 September 2005 02:23 pm, Paul Rubin wrote:
> Steven D'Aprano <steve at REMOVETHIScyber.com.au> writes:
> > It is a "mere implementation detail" that (for most computer systems, and
> > most programming languages) stack space is at a premium and a deeply
> > recursive function can run out of stack space while the heap still has
> > lots of free memory.
> Every serious FP language implementation optimizes tail calls and thus
> using recursion instead of iteration doesn't cost any stack space and
> it probably generates the exact same machine code.
I understood both the iterative version (which was efficient)
and the "naive" recursive version MUCH better than the "efficient"
Being able to write the efficient recursive version proves you're
smart, which is very important to some people. Being able to
write the efficient iterative version proves you don't have to be.
Since I write code to solve problems, not prove my intellectual
prowess, my vote goes for the "dumb" solution. Probably this
is why I use Python.
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks http://www.anansispaceworks.com
More information about the Python-list