rationale for opSlice, opSliceAssign, vs a..b being syntax suger for a Slice struct?

bearophile bearophileHUGS at lycos.com
Sat Apr 6 16:57:54 PDT 2013


Timothee Cour:

> * it breaks _orthogonality_ of features: opIndex should work 
> with
> everything (indexes, slices), whereas now we're having an 
> opSliceIndex
> that works on slices and opIndex that works on non-slices.

Don has discussed about this more than one time. Generally I 
think there is space for improvements in the D design.

If you want bring this topic in the main D newsgroup, but keep in 
mind this was already discussed one or more times.


> * it makes it hard to support future slicing functionality such 
> as stride, eg:
> x[begin..end:stride]

I think a stride is important.


> Also, compiler should be able to optimize out the underlying 
> slice object constructions,

If the slice is a small struct, it's about as efficient as normal 
arguments.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list