opIndex vs. opSlice for empty slices

Mike Parker via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri May 22 00:02:43 PDT 2015


On Friday, 22 May 2015 at 06:28:16 UTC, Ali Çehreli wrote:
>
> http://ddili.org/ders/d.en/operator_overloading.html#ix_operator_overloading.opSlice
>
>
> http://ddili.org/ders/d.en/templates_more.html#ix_templates_more.overloading,%20operator
>
> Ali

Thanks, Ali. I've actually looked over that already and it's part 
of the reason I postes the question in the first place. The docs 
indicate that opIndex can be used for the empty slice on a 
single-dimensional array, but your text says it's used for 
multi-dimensional slicing and opSlice is for the empty, single 
dimensional form. Then, in the thread linked above, H.S. Teoh's 
post seems to side with the docs.

Additionally, there's the bit in the docs that I missed earlier 
about the non-templated opSlice being kept for backward 
compatibility, but the DoubleEndedQueue in your first link use 
the non-templated opSlice rather than the templated form that 
H.S. Teoh's post demonstrated.

I've only recently started digging into the different sources of 
documentation on D to understand the why of things and, in the 
process, have managed to confuse myself about topics I thought I 
understood. I'm finding it hard to discern which source is 
correct and why.


More information about the Digitalmars-d-learn mailing list