Consistency

John Colvin via Digitalmars-d digitalmars-d at puremagic.com
Mon Feb 16 05:23:58 PST 2015


On Monday, 16 February 2015 at 13:10:44 UTC, Daniel Murphy wrote:
> "Marc Schütz" " wrote in message 
> news:iftpzvhoyxxqhbfsxull at forum.dlang.org...
>
>> To be really consistent,
>>     x in arr
>> would need to be equivalent to:
>>     (x >= 0) && (x < arr.length)
>>
>> `in` tests for the presence of a _key_ in AAs, and the 
>> equivalent notion of a key for arrays is an index.
>
> It's called 'in', not 'haskey'.  Is 3 in the array?  Is 7 in 
> the map? Everybody understands what it means and the whole 
> argument is nonsense. Next somebody will be arguing that 
> float/float and int/int aren't the same operation and should 
> have different syntax.

I'm quite a fan of python's // operator for integer division, 
especially when combined with python 3's choice to make / always 
mean floating point division (i.e. 3/2 == float(3)/2, 3//2 == 1). 
It recognises that integer division is a weird thing and 
separates it from the much less weird floating point division.


More information about the Digitalmars-d mailing list