Python's "only one way to do it" philosophy isn't good?
Josiah Carlson
josiah.carlson at sbcglobal.net
Mon Jun 11 02:36:25 EDT 2007
Paul Rubin wrote:
> Steven D'Aprano <steve at REMOVE.THIS.cybersource.com.au> writes:
>>> Not tail calls, in general, no.
>> Sorry, how does that work? You're suggesting that there is an algorithm
>> which the compiler could follow to optimize away tail-recursion, but human
>> beings can't follow the same algorithm?
>>
>> Now I'm confused.
>
> The usual compiler method is to translate the code into
> continuation-passing style and thereby gain tail-recursion
> optimization automagically. Of course a human could do the same thing
> in principle, but it would result in insanely difficult-to-write,
> unreadable and unmaintainable code. At a higher level, there are no
> Python features whatsoever, either existing or proposed, that couldn't
> be eliminated and left to the human. Iterators? While loops? Who
> needs 'em? We could all go back to programming in machine code. But
> Python is supposed to make programming easier, not harder.
Thanks to Richie Hindle, there exists a goto for Python implementation
that makes such things quite trivial (assuming one doesn't like
"abusing" break/continue/else). http://entrian.com/goto/ (which, by
the way, is the best April-fools joke ever)
- Josiah
More information about the Python-list
mailing list