Better slicing
Jari-Matti Mäkelä
jmjmak at utu.fi.invalid
Wed Mar 8 12:45:18 PST 2006
Tom wrote:
> In article <dun61g$30be$1 at digitaldaemon.com>, NN says...
>> What about more powerful slicing, like e.g. in Python ?
>>
>> char[] x;
>>
>> char[] y = x[0 : x.size : 1];
>> char[] y = x[x.size : 1]; // Same
>>
>> char[] z = x[x.size : 0 : -1]; // Reverse
>> char[] z = x[x.size :: -1]; // Same
>>
>> // Maybe with D syntax
>> char[] x;
>>
>> char[] y = x[0 .. x.size .. 1];
>> char[] y = x[x.size .. 1]; // Same
>>
>> char[] z = x[x.size .. 0 .. -1]; // Reverse
>> char[] z = x[x.size .. .. -1]; // Same
>
> I think it's enough how it is now. We'll never reach 1.0 if we keep adding
> "luxuries" to the language, of course it's my humble oppinion. Instead I would
> suggest to complete unfinished features, fix bugs and, if it is possible, to
> make the almighty constness implementation in some way ;-).
I agree. I think we can already do all these with the currently
implemented slicing and .reverse-operations. The syntax with negative
indices IMHO doesn't fit in D.
--
Jari-Matti
More information about the Digitalmars-d
mailing list