Using the Python Interpreter as a Reference

Chris Angelico rosuav at gmail.com
Mon Nov 28 21:57:32 EST 2011


On Tue, Nov 29, 2011 at 1:42 PM, Travis Parks <jehugaleahsa at gmail.com> wrote:
> A good example I have run into is recursion. When a local function
> calls itself, the name of the function may not be part of scope (non-
> local). Languages that support tail-end recursion optimization can't
> optimize. In order to support this, a function in Unit will have
> access to its own name and type. In other words, special scoping rules
> are in place in Unit to allow treating a function as an expression.

I'm inclined toward an alternative: explicit recursion. Either a
different syntax, or a special-case on the use of the function's own
name, but whichever syntax you use, it compiles in a "recurse" opcode.
That way, if name bindings change, it's still going to recurse -
something few languages guarantee, and therefore few languages can
optimize.

ChrisA



More information about the Python-list mailing list