No macros in Python

Bengt Richter bokr at oz.net
Tue Dec 17 00:16:51 EST 2002


On 17 Dec 2002 03:15:08 GMT, bokr at oz.net (Bengt Richter) wrote:
[...]
>E.g., what if you could take an ordinary code "suite" such as would be indented
>under, e.g., "if bar:" but instead of the if and its expression, there would
>be a keyword and a name which would label the suite, so you could refer to it later.
>The suite would be compiled just as if it were under an if statment
>(i.e., all symbols refer to the local namespace), but execution would skip over
>it like an embedded def (or if 0:).
Make that "like an if 0:"
Of course an ordinary embedded def is really not "skipped over" -- it is executable
code that binds the function name to stuff pulled together to make a function.

I was thinking of the new local def I am proposing, which in contrast does not
bind separately compiled code, but defines local compiled code that is
as much part of the current code as an if statement suite in the same position
would be. In fact, identical except for a new local return byte code at the end,
given that the def parameter declaration guarantees that local bindings for them
exist for the suite. Thought I'd better clear that up ;-)

Regards,
Bengt Richter



More information about the Python-list mailing list