PEP308: Yet another syntax proposal

James J. Besemer jb at cascade-sys.com
Tue Feb 11 08:28:55 CET 2003


Aahz wrote:

>>Not true, as I and others have explained at length elsewhere.  Readability 
>>and maintainability are SERVED by factoring out common sub-expressions from 
>>the more verbose forms:
>>
>>    if condition1:
>>        if condition2
>>                targetVar1 = result1
>>            else:
>>                targetVarl = result2		# hidden BUG!!
>>    else:
>>        targetVar1 = result3
> 
> 
> How is what you're saying here an argument against a conditional
> function?  

Once again, you pointlessly stoop to emphasize the painfully obvious. 
Obviously my example in this case has nothing to do with conditional 
evaluation.  The more astute readers probably gleaned from the text that I 
was in this case working on a different point altogether.  Yes, these 
particular important benefits apply equally well to your iff() proposal.

> Seems to me that short-circuit is the *only* reason to dislike iif();

I dislike it because it's a functional form for what should be a standard 
operator.

I further object to it's pointlessness, as in the absence of conditional it 
won't provide a viable alternative to the inferior and/or idiom.  I suspect 
you like it so much precisely because it essentially defeats the PEP.

> and therefore you need to make your argument on changing the language
> (rather than the library) solely on the short-circuit point.  That's a
> lot tougher, I think.

True.

But if he approves the proposal at all, I trust that Guido will see the 
wisdom of going ahead and including the short circuit functionality, various 
'statistical' and emotional arguments of dubious validity notwithstanding.

After all, short circuit functionality was integral to his original draft PEP 
AND to the reference implementation he worked on previously.  As some have 
acknowledged, it's a slightly 'advanced' feature and perhaps only the wiser 
of us understand how it's significant merit outweighs the minor cost.

While I doubt he has the stamina to keep up with all the volume coming down 
this fire hose of late (especially given the higher than normal fecal 
content), I do believe he sees or hears a representative sampling of the 
various arguments.  I trust him to give much greater weight to the logical 
ones vs. the emotional ones.

[BREAKING NEWS]

Ha!  Amazingly, while we were arguing (and, seriously, after writing the 
above part of this reply), I see that the PEP author has seen the wisdom of 
some of our arguments, and now has revised PEP-308, proposing a form which 
many may find agreeable.

	http://www.python.org/peps/pep-0308.html

Better yet, and more relevant to your question, the revised PEP includes 
mention of something like your iff() and then rejects it because, among other 
things,

	BDFL opposes *any* solution that does
	NOT provide short circuit behavior.

Furthermore, there's an entire section devoted to the motivation for short 
circuit.  Can you say, "End of discussion?"

I'm sure glad I waited until late tonight to begin to address this 
(admittedly harder) issue.  And I'm even gladder that I double checked the 
PEP before attempting it, especially after such a long day.  Best of all, I'm 
glad to find that my trust in the right hon. BDFL was not misplaced, though 
I'm amazed and astonished how quickly he came through.

Nighty night, all, and sleep tight.

--jb

-- 
James J. Besemer		503-280-0838 voice
2727 NE Skidmore St.		503-280-0375 fax
Portland, Oregon 97211-6557	mailto:jb at cascade-sys.com
				http://cascade-sys.com	







More information about the Python-list mailing list