(no) fast boolean evaluation ?
bruno.42.desthuilliers at wtf.websiteburo.oops.com
Fri Aug 3 17:57:30 CEST 2007
Steven D'Aprano a écrit :
> On Fri, 03 Aug 2007 10:20:59 +0200, Bruno Desthuilliers wrote:
>> Joshua J. Kugler a écrit :
>>> On Thursday 02 August 2007 15:19, Evan Klitzke wrote:
>>>>> I discovered that boolean evaluation in Python is done "fast"
>>>>> (as soon as the condition is ok, the rest of the expression is ignored).
>>>> This is standard behavior in every language I've ever encountered.
>>> Then you've never programmed in VB (at least 6, don't know if .net still
>>> does this). Nested IF statements. AAAAAAAAAAAAAAAAAAAACK!
>> I do remember an even brain-deadiest language that not only didn't
>> short-circuit boolean operators but also didn't have an "elif" statement...
> Is it a secret?
> I'm a little perplexed at why you say a language without "elif" is a good
> sign of brain-death in a programming language. I understand that, given
> the parsing rules of Python, it is better to use elif than the equivalent:
> if condition:
> if another_condition:
> But that's specific to the syntax of the language. You could, if you
> choose, design a language where elif was unnecessary:
> if condition:
> else if another_condition:
> What advantage is there to "elif", apart from it needing three fewer
> characters to type?
Sorry, I forgot to mention the language did not allow to have else & if
in the same statement. IOW :
if some_condition then
if some_other_condition then
if yet_another_condition then
if your_still_here then
give_up('this language is definitively brain dead')
More information about the Python-list