"Bengt Richter" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> I think the relationship of abstract entities and their concrete 
> representations
> is very interesting.

ditto

> BTW, maybe this is a place to mention the concept of an AST decorator, 
> that works like
> a function decorator except that it is prefixed with @@ instead of @ and 
> it operates
> at compile time when the AST becomes available, but before it gets 
> translated to code,
> and what gets passed to the decorator is the AST

One can do this much today:

import compiler

new_ast = ast_transformer(compiler.parse('''\
<code here>
''')

However, I can't see any way in the docs to get a code object from the AST. 
I believe the AST-to-code compilet is currently being worked on.  When it 
is, @@ would be nice syntactic sugar but not really necessary.

> The idea is that this form of decoration could transform the
> AST arbitrarily before code generation, and be a very flexible tool
> for mischief of course, but also useful tricky things.

At the moment, we are limited to manipulating concrete text before 
compiling it.

Terry J. Reedy



-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to