Python is not bad ;-)
Christian Gollwitzer
auriocus at gmx.de
Fri May 1 13:56:02 EDT 2015
Am 01.05.15 um 09:03 schrieb Steven D'Aprano:
> On Thu, 30 Apr 2015 09:30 pm, Cecil Westerhof wrote:
>
>> Tail recursion would nice to have also.
>
> People coming from functional languages like Lisp and Haskell often say
> that, but how many recursive algorithms naturally take a tail-call form?
> Not that many.
That is because tailcall optimization is used in functional languages
mainly as a replacement for loops. IOW, in non-functional languages you
can simply use an infinite loop to do the same (in most cases).
> I suppose that it would be nice if Python let you optionally use tail-call
> optimization, but that might be tricky in practice.
>
In Tcl 8.6 there is an explicit "tailcall something" command which calls
something without creating a new stack frame, i.e. it returns to the
caller after something returns. Useful sometimes, but more a
micro-optimization than a vital feature.
Christian
More information about the Python-list
mailing list