<div dir="ltr"><div class="gmail_quote"><span class="Apple-style-span" style="font-size: small;">On Wed, Sep 17, 2008 at 3:41 PM, Cliff Wells </span><span dir="ltr"><span class="Apple-style-span" style="font-size: small;"><<a href="mailto:cliff@develix.com">cliff@develix.com</a>></span></span><span class="Apple-style-span" style="font-size: small;"> wrote:<br>
</span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><span class="Apple-style-span" style="font-size: small;">I'd prefer to write<br><br>
def foo ( lambda: arg ):<br>
return arg # evaluation happens here<br>
foo ( x )<br><br>
("lambda" not necessarily being the actual name of the token in the<br>
second case).</span>
</blockquote><div><span class="Apple-style-span" style="font-size: small;"><br></span></div><div><span class="Apple-style-span" style="font-size: small;">I'd rather use the time machine. You can already do this quite easily. </span></div>
<div><span class="Apple-style-span" style="font-size: small;"><br></span></div><div><span class="Apple-style-span" style="font-size: small;">def foo (arg):<br> return arg() # evaluation happens here<br>foo(lambda: x)<br>
</span></div><div><span class="Apple-style-span" style="font-size: small;"><br></span></div><div><span class="Apple-style-span" style="font-size: small;">or</span></div><div><span class="Apple-style-span" style="font-size: small;"><br>
</span></div><div><div><span class="Apple-style-span" style="font-size: small;">def IF(c,t,f=lambda:None):</span></div><div><span class="Apple-style-span" style="font-size: small;"> if c:</span></div><div><span class="Apple-style-span" style="font-size: small;"> return t()</span></div>
<div><span class="Apple-style-span" style="font-size: small;"> else:</span></div><div><span class="Apple-style-span" style="font-size: small;"> return f()</span></div></div><div><span class="Apple-style-span" style="border-collapse: collapse; "><span class="Apple-style-span" style="font-size: small;">IF(hasattr(spam, 'eggs'), lambda: spam.eggs, lambda: 'not found')</span></span><span class="Apple-style-span" style="font-size: small;"><br>
</span></div><div><span class="Apple-style-span" style="border-collapse: collapse;"><span class="Apple-style-span" style="font-size: small;"><br></span></span></div><div><span class="Apple-style-span" style="border-collapse: collapse;"><span class="Apple-style-span" style="border-collapse: separate; "><span class="Apple-style-span" style="font-size: small;">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.</span></span></span></div>
<div><br></div><div><span class="Apple-style-span" style="border-collapse: collapse;"><span class="Apple-style-span" style="border-collapse: separate; "><span class="Apple-style-span" style="font-size: small;">--- Bruce </span></span><br>
</span></div></div></div>