[Python-3000] Wild idea: Deferred Evaluation & Implicit Lambda
Alexander Belopolsky
alexander.belopolsky at gmail.com
Wed May 31 20:51:14 CEST 2006
Talin <talin <at> acm.org> writes:
[snip]
> One way around that would be to have the 'lazy' attribute associated
> with the formal parameter of the called function instead:
>
> def getitem( self, key, lazy default_val ):
> ...
>
> Unfortunately, this breaks the "no programmable syntax" rule - because
> there's no way for a given program to know whether or not the function
> being called has a lazy argument or not. I don't know of a way around
> this, to be honest, so this idea won't work unless someone out there has
> some clever idea that I haven't thought of.
[snip]
On the first reading I did not realize that Talin proposed that laziness be
specified at the definition rather than at the call site.
This is a much more interesting and more difficult to implement idea than the
simple "promise" proxy that I described. This idea does appear to be crossing
the "programmable syntax" line unless f(...) is made to always push unevaluated
arguments to the stack and the evaluation of arguments is handled by the
CALL_FUNCTION op-code. In the later case, the evaluation can be guided by the
information associated with the function object. I believe type annotations
would provide a natural place to specify this extra information. If
CALL_FUNCTION finds an undecorated function object on the stack, it would
just evaluate all the arguments and proceed as in 2.x, but if type decoration
is available, arguments specified as promise[interface] will be wrapped in
proxies supporting the given interface. Mixing "pass by" information with
the type annotations has an additional advantage of solving the problem of
when a promise should be fulfilled: at the time when an interface method is
called.
This is still far from a proposal, I've just tried to describe something that
I think is implementable.
More information about the Python-3000
mailing list