'$' and opDollar

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sat Jan 1 11:06:39 PST 2011


On 1/1/11 12:27 PM, Don wrote:
> spir wrote:
>> Hello,
>>
>>
>> [This is another currently unfixed point of D2 that prevents us
>> implementing our project the way we wish it.]
>>
>> AFAIK, using '$' for custom collection types is not yet possible:
>> oDollar is simply not implemented (correct?). But why do we need it? I
>> do not understand the logic requiring an opDollar special method to
>> "desugarise" the '$' operator. For me, '$' simply means length, so I
>> would be fully happy with the simple rewrite of
>> coll[$] coll[$-i] coll[i..$]
>> to
>> coll[coll.length] coll[coll.length-i] coll[i..coll.length]
>
> The problem is with multi-dimensional indices.
> Consider:
> a[$-1][$-2];
>
> There are two different values for $.

TDPL has solved that once and for all. The design hasn't been yet 
implemented.

Andrei


More information about the Digitalmars-d mailing list