'$' and opDollar

Don nospam at nospam.com
Sat Jan 1 10:27:57 PST 2011


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 $.



More information about the Digitalmars-d mailing list