www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Re: A possible solution for the opIndexXxxAssign morass

reply Kagamin <spam here.lot> writes:
Robert Jacques Wrote:

 Also needed is an extension of the opDollar to return different values  
 based on the index:
 opDollar(size_t index);

Dollar is just a synonym for length, isn't it?
Oct 14 2009
next sibling parent reply "Lars T. Kyllingstad" <public kyllingen.NOSPAMnet> writes:
Kagamin wrote:
 Robert Jacques Wrote:
 
 Also needed is an extension of the opDollar to return different values  
 based on the index:
 opDollar(size_t index);

Dollar is just a synonym for length, isn't it?

Yes, but if opIndex and opSlice take multiple indices (like in a matrix) opDollar needs a way to distinguish between the different dimensions. -Lars
Oct 14 2009
next sibling parent Kagamin <spam here.lot> writes:
Lars T. Kyllingstad Wrote:

 Yes, but if opIndex and opSlice take multiple indices (like in a matrix) 
 opDollar needs a way to distinguish between the different dimensions.

size_t length(size_t idx);
Oct 14 2009
prev sibling parent Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
Lars T. Kyllingstad wrote:
 Kagamin wrote:
 Robert Jacques Wrote:

 Also needed is an extension of the opDollar to return different 
 values  based on the index:
 opDollar(size_t index);

Dollar is just a synonym for length, isn't it?

Yes, but if opIndex and opSlice take multiple indices (like in a matrix) opDollar needs a way to distinguish between the different dimensions. -Lars

I think the compiler should rewrite $ to __currentarray.length in unary index expressions, and to __currentarray.length!(n) in multiple index expressions. Andrei
Oct 14 2009
prev sibling parent "Robert Jacques" <sandford jhu.edu> writes:
On Wed, 14 Oct 2009 06:11:22 -0400, Kagamin <spam here.lot> wrote:

 Robert Jacques Wrote:

 Also needed is an extension of the opDollar to return different values
 based on the index:
 opDollar(size_t index);

Dollar is just a synonym for length, isn't it?

User types can also override Dollar, though I don't remember off the top of my head how.
Oct 14 2009