functional programming

Paul Svensson paul at svensson.org
Sat Feb 26 15:55:33 EST 2000


"Tim Peters" <tim_one at email.msn.com> writes:

>[Moshe Zadka]
>
>> And I don't mind at all having Python do no optimization as long as I
>> do not give the flag -believe-me-I-really-do-want-tail-call-
>> optimization <0.5 wink>
>
>I'm afraid it's not that simple (but what is <wink>?).  If Python has a mode
>that guarantees to optimize tail calls, some people will use it, some of
>those will write code that *relies* on it to avoid blowing the stack, some
>of those will distribute modules so relying, and then users get sucked into
>either (a) running code that uses those modules with the magic switch too,
>or (b) not using the switch and suffering "mysterious data-dependent
>failures".  Both complicate Python's story and so Python users' lives too.
>It's a tradeoff in practice:  perhaps *you* wouldn't do this to users, but
>others will.  A language is doomed to support everything it permits, and
>usually forever.

I see only one obvious solution here we must allow the programmer to make
the choise of dropping or keeping the stack frame, not once for the whole
interpreter run, but rather individually for each return.  This can easily
be done by adding an alternate spelling of the return statement, something
it appears that Guoido have already forethought, by not using the spelling
'goto' anywhere else in the language.  This is such a simple and beautiful
change, that even those who are vehemently opposed to adding new keywords
to tha language can not resist it, for surely, no sane python program would
have been using such a word already ?

	/Paul



More information about the Python-list mailing list