opSlice and $

Sean Kelly sean at f4.ca
Tue Sep 11 12:30:32 PDT 2007


Oskar Linde wrote:
> Sean Kelly wrote:
>> Russell Lewis wrote:
>>> It appears to me, looking at the spec, that there isn't a way to 
>>> support the use of $ in operator overloading.  Is there anything I've 
>>> overlooked?  What I'm looking for, of course, is to be able to do:
>>>
>>> class MyClass {....}
>>>
>>> MyClass c = new MyClass;
>>> auto x = c[1..$];
>>
>> The '$' symbol should map to "size_t length()" when used with opSlice, 
>> but at the moment I don't think this is the case.
> 
> The problem how that generalizes to multidimensional slicing:
> c[1..$, 2..$]
> 

Ugh.  I guess we'd need an opLength after all, huh?


Sean



More information about the Digitalmars-d mailing list