digitalmars.D - Re: A possible solution for the opIndexXxxAssign morass
- Kagamin <spam here.lot> Oct 14 2009
- "Lars T. Kyllingstad" <public kyllingen.NOSPAMnet> Oct 14 2009
- Kagamin <spam here.lot> Oct 14 2009
- Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> Oct 14 2009
- "Robert Jacques" <sandford jhu.edu> Oct 14 2009
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
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
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
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
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