[pypy-dev] Non standard ASTs

Armin Rigo arigo at tunes.org
Tue Dec 13 16:06:41 CET 2011


Hi,

On Tue, Dec 13, 2011 at 15:41, Timothy Baldridge <tbaldridge at gmail.com> wrote:
> 1) multiline closures (lambdas with more than one statement)
> 2) IfExpr with multiline bodies.

It just shows that you're trying to stuff too much things into
Python's limited expressions.  You need instead to produce complete
statements, with extra temporary variables.  For example: turn code
like "if x then a; b; else c" (random syntax example) into:

   if cond:
       a
       result = b
   else:
       result = c

and then use 'result'.

Yes, indeed, Python is not the best language for generating source or
AST directly for, but it can be done.


A bientôt,

Armin.


More information about the pypy-dev mailing list