Few things

renoX renosky at free.fr
Thu Aug 2 12:45:46 PDT 2007


Sean Kelly a écrit :
> bearophile wrote:
>> 4) Python defines < <= == != >= > among dicts (AAs) too:
>>
>>>>> {1:2, 2:3} == {1:2, 2:3}
>> True
>>>>> {1:3, 2:3} == {1:2, 2:3}
>> False
>>>>> {1:2, 2:3} < {1:2, 2:3}
>> False
>>>>> {1:2, 2:3} > {1:2, 2:3}
>> False
>>>>> {1:2, 2:3, 3:1} > {1:2, 2:3}
>> True
>>>>> {1:2, 2:3, 3:1} > {1:2, 2:3, 4:1}
>> False
>>>>> {1:2, 2:3, 3:1} < {1:2, 2:3, 4:1}
>> True
>>
>> It seems not even the quite useful opEquals among AAs is defined yet 
>> in dmd V1.015:
>> assert(['a':2, 'b':3] == ['a':2, 'b':3]);
> 
> Seems handy, and more consistent than the current behavior.

While I agree with ==, I'm a bit puzzled by '<': is-it always possible 
to order keys and values?
And if it isn't possible what will happen, a compile time error?


>> 7) From the FAQ: >Many people have asked for a requirement that there 
>> be a break between cases in a switch statement, that C's behavior of 
>> silently falling through is the cause of many bugs. The reason D 
>> doesn't change this is for the same reason that integral promotion 
>> rules and operator precedence rules were kept the same - to make code 
>> that looks the same as in C operate the same. If it had subtly 
>> different semantics, it will cause frustratingly subtle bugs.<
>>
>> I agree with both points of view. My idea: calling this statement 
>> differently (like caseof) instead of "switch" (like in Pascal), so you 
>> can change its semantics too, removing the falling through (you may 
>> use the Pascal semantic too).
> 
> It's a good idea, but I actually like the fall-through behavior.  I use 
> it regularly.

Sure, fall-through behaviour is useful sometimes, but it shouldn't be 
the default.. Pascal semantic isn't good enough as it didn't have a way 
to allow fall-through but this could be added..

renoX





More information about the Digitalmars-d mailing list