DIP58: ".." as a Binary Operator

Chris Williams yoreanon-chrisw at yahoo.co.jp
Mon Mar 17 12:42:58 PDT 2014


On Monday, 17 March 2014 at 19:07:45 UTC, Mason McGill wrote:
> On Monday, 17 March 2014 at 17:41:16 UTC, bearophile wrote:
>> Mason McGill:
>>
>>> http://wiki.dlang.org/DIP58
>>
>> Seems nice.
>
> Thanks.  There are a few awkward parts to maintain 
> compatibility, but that seems to be the only way to go.
>
>> But the syntax a..b..step is not very nice.
>
> Do you not like the order?  Because it was actually a..step..b 
> (like MATLAB/Julia, not like Python).  Or do you not like the 
> "verbosity" of all those dots (a:step:b would be better)?  Or 
> is it the readability issues if floating point literals were 
> mixed in there?
>
>>
>> Bye,
>> bearophile

Random thought, but treating step as a template argument would 
allow for some more interesting changes to the iterations, though 
I can't think of any particular syntax that would look good. And 
if you did add such a thing, then other operators would want it 
as well.

int[] foo = a ..!"a += 10" b;
bool equals = dbl1 ==."abs(a - b) < 0.01" dbl2


More information about the Digitalmars-d mailing list