A possible lazy evaluation system?
Stephen Horne
intentionally at blank.co.uk
Tue Mar 11 07:59:33 EST 2003
I one mentioned that I thought it was sensible to label function
parameters in some way to modify the call mechanism. The obvious
analogy is 'var' parameters in Pascal, though I was thinking more of a
'lazy' modifier.
It occured to me that, instead of a fully lazy parameter system, a
simpler approach may be to lable parameters as lambdas.
You could then write something like...
def IF (c, lambda x, lambda y) :
if c :
return x ()
else :
return y ()
...and call it with...
IF (y != 0, x/y, 1000000)
The 'lambda' asserts that the parameters expression gets converted to
a parameterless lambda instead of being evaluated immediately.
The same notation in declarations of __call__ could provide the same
capability to all callables.
The question is - is this a sane suggestion?
More information about the Python-list
mailing list