DMD 0.177 release [Length in slice expressions]

Oskar Linde oskar.lindeREM at OVEgmail.com
Tue Dec 26 07:16:20 PST 2006


== Quote from Reiner Pope (xxxxxx at xxx.xx)'s article
> Is there anything particularly wrong with having foo[a..b,c,d..$] being
> syntactical sugar for foo[a..b][c][d..$] ? That way, I would imagine you
> could implement slicing and indexing of multidimensional arrays quite
> easily because, as Norbert Nemec said, indexing just returns an array
> with dimension reduced by one, and slicing returns an array of the same
> dimension, but perhaps different size. It also seems to allow any
> combination of slicing and indexing without needing variadic functions.

It is a neat idea that unfortunately doesn't work.

foo[a..b,c..d] means slice from a to b along dimension 1 and from c to d
along dimension 2. foo[a..b] would therefore return a 2-dimensional slice
(same dimensionality as foo), and (foo[a..b])[c..d] would slice the same
dimension again. Unless, of course, foo[a..b] would return some kind of proxy
object that kept track of the last sliced dimension.

/Oskar



More information about the Digitalmars-d-announce mailing list