digitalmars.D.learn - opDollar()
-
Caligo
(6/6)
Mar 26 2011
"In the expression a[
, ..., ], if $ occurs in - Dmitry Olshansky (13/19) Mar 26 2011 That parameter means number of dimension. When implementing some kind of...
- Don (2/23) May 02 2011
"In the expression a[<expr 1>, ..., <expr k>], if $ occurs in <expr i>, it is rewritten as a.opDollar!(i)()." -- TDPL, pg 380 Is that correct? if so, could some one give an example code? I don't understand the need for the parameter. Also, what is the signature for opDollar() in a struct. I'm getting errors trying to implement this.
Mar 26 2011
On 26.03.2011 11:03, Caligo wrote:"In the expression a[<expr 1>, ...,<expr k>], if $ occurs in<expr i>, it is rewritten as a.opDollar!(i)()." -- TDPL, pg 380 Is that correct? if so, could some one give an example code? I don't understand the need for the parameter. Also, what is the signature for opDollar() in a struct. I'm getting errors trying to implement this.That parameter means number of dimension. When implementing some kind of multidimensional array (e.g. an 2D raster Image) you'd have: img[$-1, $-1] = lastValue; // the first dollar should resolve to "width", the second to "height" Now speaking of it's implementation - it's quite broken. The relevant bug report is http://d.puremagic.com/issues/show_bug.cgi?id=3474 (vote up!) Still it's not considered to be a critical one, since you can workaround it by: img[img.width-1,img.height-1] = lastValue; -- Dmitry Olshansky
Mar 26 2011
Dmitry Olshansky wrote:On 26.03.2011 11:03, Caligo wrote:It's not broken -- it's not implemented at all!"In the expression a[<expr 1>, ...,<expr k>], if $ occurs in<expr i>, it is rewritten as a.opDollar!(i)()." -- TDPL, pg 380 Is that correct? if so, could some one give an example code? I don't understand the need for the parameter. Also, what is the signature for opDollar() in a struct. I'm getting errors trying to implement this.That parameter means number of dimension. When implementing some kind of multidimensional array (e.g. an 2D raster Image) you'd have: img[$-1, $-1] = lastValue; // the first dollar should resolve to "width", the second to "height" Now speaking of it's implementation - it's quite broken.The relevant bug report is http://d.puremagic.com/issues/show_bug.cgi?id=3474 (vote up!) Still it's not considered to be a critical one, since you can workaround it by: img[img.width-1,img.height-1] = lastValue;
May 02 2011