Python's "only one way to do it" philosophy isn't good?

Terry Reedy tjreedy at udel.edu
Mon Jun 11 18:07:54 EDT 2007


|> | > Terry Reedy wrote:
|> | > > In Python, you have a choice of recursion (normal or tail)

Bruno
> | I'm afraid Terry is wrong here, at least if he meant that CPython had
> | tail recursion *optimization*.

| Terry Reedy a écrit :
| > NO!!!
| > I did not mean that or imply that in any way.

Bruno
| I understand you didn't mean it, but since the whole point of
| tail-recursion is allowing optimisation

Wrong again.  That is a reason, even a primary reason, for some people some 
of the time, but not at all the only reason anyone would ever write linear 
recursion in tail rather than body (my term) form.  So nothing follows from 
this false premise.

| (else tail-recursion is nothing else than a subset of recursion)

So?  Body-recursion (non-tail-recursion) is also nothing else than a subset 
of recursion.

| you somehow implied it, even while that was not your intention.

False in its own right.  Any langauge that allow recursion allows the 
subset that happen to constitute tail recursion.  Most do not *mandate* 
that compilers specially recognize and optimize that subset.  So there is 
pragmatically no implication that the latter follows from the former.

The reason I specifically mentioned tail recursion is because Prof. 
Sussman, who complained about
   There should be one-- and preferably only one --obvious way to do it.
-- to quote Brother Tim accurately -- co-developed Scheme.  To me, Scheme 
promotes tail recursion as the one true way as much or more as anything is 
similarly promoted in Python.  That mention had nothing in itself to do 
with the separate issue of optimizing tail calls.

What Sussman apparently missed is that Tim's main point is that there 
should be some rather than no obvious way to do things.  The parenthetical 
optional secondary desiderata is just that -- optional and secondary.

Terry Jan Reedy






More information about the Python-list mailing list