[Python-ideas] And now for something completely different
bruce at leapyear.org
Thu Sep 18 01:18:38 CEST 2008
On Wed, Sep 17, 2008 at 3:41 PM, Cliff Wells <cliff at develix.com> wrote:
> I'd prefer to write
> def foo ( lambda: arg ):
> return arg # evaluation happens here
> foo ( x )
> ("lambda" not necessarily being the actual name of the token in the
> second case).
I'd rather use the time machine. You can already do this quite easily.
def foo (arg):
return arg() # evaluation happens here
IF(hasattr(spam, 'eggs'), lambda: spam.eggs, lambda: 'not found')
The idea of something automagically changing from an unevaluated to an
evaluated value strikes me as a very bad one so requiring explicit
evaluation here is a *good* thing. Aside from that, why should arg be
evaluated on return as opposed to being passed along unevaluated until its
value is really needed? How would I check to see if an arg was provided? I
certainly can't use a default value of None and then check for None since
the check would cause it to be evaluated. Maybe we have a special operator
that allows us to look at the unevaluated value. What's the context of the
evaluation? Can it access variables in the place where it's evaluated? Maybe
there's a special way to do that too. Let's not go down that path.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas