'$' and opDollar

spir denis.spir at gmail.com
Sat Jan 1 10:54:37 PST 2011


On Sat, 01 Jan 2011 19:27:57 +0100
Don <nospam at nospam.com> wrote:

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

Right. I don't understand why a solution like length does not apply, and why opDollar would. In the above example, both a and a[$-1] should have a length member or an opDollar method. What do I misinterpret?

Denis
-- -- -- -- -- -- --
vit esse estrany ☣

spir.wikidot.com



More information about the Digitalmars-d mailing list