[Python-ideas] Alternative to PEP 532: delayed evaluation of expressions

Greg Ewing greg.ewing at canterbury.ac.nz
Sun Nov 6 16:28:12 EST 2016


Eric V. Smith wrote:

> I'd rather see the ability to have unevaluated expressions, that can 
> later be evaluated. I'll use backticks here to mean: "parse, but do not 
> execute the enclosed code". This produces an object that can later be 
> evaluated with a new builtin I'll call "evaluate_now".

So far you've essentially got a compact notation for a
lambda with no arguments. Suggestions along these lines
have been made before, but didn't go anywhere.

> You could go further and say that any argument to a function that's 
> specially marked would get an unevaluated expression. Suppose that you 
> can mark arguments as & to mean "takes an unevaluated expression".

Now *that* would be truly interesting, but it would
complicate some fundamental parts of the implementation
tremendously. Before calling any function, it would be
necessary to introspect it to find out which parameters
should be evaluated. Alternatively, every parameter
would have to be passed as a lambda, with the function
deciding which ones to evaluate. I fear this would be
far too big a change to swallow.

-- 
Greg


More information about the Python-ideas mailing list