[Python-ideas] Tail Call Optimization -- natural? intuitive?
spir
denis.spir at gmail.com
Mon Jan 20 13:12:31 CET 2014
On 01/19/2014 11:32 PM, musicdenotation at gmail.com wrote:
> It fits peoples' brains more because of familiarity, not "nature".
That people often use "intuitive" or "natural" instead of "famliar" or "usual"
does not mean, logically, that there is no better intuitive or natural choice.
That people misuse a term does not imply it has no proper meaning.
For instance, closed intervals are more intuitive or natural, obviously (but for
some reason I don't know). If you ask someone to count from 1 to 9, you will
probably be surprised to hear him/her start from 2 or stop after 8. If you are
asked to choose a letter between c and g, you will probably be surprised to hear
that 'c' or 'g' is no good choice.
[This does not mean that closed intervals are the right choice in programming,
i'm just discuting the notions of intuitive or natural; this is related to the
way we spontaneously think or understand. Programming may require unintuitive or
unnatural design choices, for some other, independant reasons; dunno. For the
matter, I think the right choice may be neither [i,j] closed nore [i,k[
half-closed intervals, but (i,n) ranges, where n is the number of items.]
About the case of recursivity, whether it may be intuitive or natural, I think
(see some previous post) that is very, very hard to judge. It is so abstract,
and obviously difficult to catch. It require understanding recurrence (remember
difficulty of most people at school?) and then tuuning it inside out *in mind*
like a sock ;-), to produce an algo running backwards, and still understanding
that it will do the right thing (because in fact it computes forwards behind the
stage, which is totally implicit, and again hard to get).
About optimisation of tail calls, I share Guido's "pronouncement". Mainly
because these optimisable (backward) recursive algo are the ones one can easily
express by a forward algo (using loops and/or corecursivity), if I understanding
the issue well (which i'm not 100% sure, but I don't know any counter-example).
The issue of stack traces and programmer feedback is just for me another reason
(not decisive because such algos often require inserting debug prints anyway, to
understand what actually happens and/or diagnose a bug).
Denis
More information about the Python-ideas
mailing list