Range literals
Norbert Nemec
Norbert at Nemec-online.de
Tue Aug 24 01:22:24 PDT 2010
On 24/08/10 08:56, Peter Alexander wrote:
> Proposal: Make a..b a literal that evaluates to iota(a, b) or some
> built-in equivalent.
Indeed, this has been discussed before and I believe people were
generally in favor of this idea. I agree that it should still be
considered for DMD2. As I see it, this would not be a new feature on its
own, but rather a modification to round up the existing set of features.
> Of course, the $ symbol would not be valid for
> these literals.
Indeed -- the $ has nothing to do with the "range" but rather with the
indexing expression within which it appears.
> I also have a proposal for slicing along the same lines, but I'll leave
> that for later.
This was discussed along with it and is actually essential for the
concept: With a..b turning into an expression of its own, 'opSlice' is
not needed any more. The same effect could be achieved by overloading
opIndex for the range expression's type.
The whole idea is crucial for implementing multidimensional arrays. It
is the simplest way to allow implementing mixed indexing expressions like
myarray[a,b..c,d]
More information about the Digitalmars-d
mailing list