opIndex() may hide opSlice()

XavierAP via Digitalmars-d digitalmars-d at puremagic.com
Thu Mar 9 17:34:13 PST 2017


On Friday, 10 March 2017 at 01:10:21 UTC, H. S. Teoh wrote:
> On Fri, Mar 10, 2017 at 01:07:33AM +0000, XavierAP via 
> Digitalmars-d wrote:
>> 
>> Should not the overload of opSlice() with no arguments be 
>> deprecated?
>> Am I missing something?
>
> Using opSlice() for slicing (i.e., arr[]) is old, 
> backward-compatible
> behaviour.

Yes but again, why not deprecate it, while still supporting it?

It could same someone from having their code hidden and replaced 
in a polymorphic scenario. Granted it may not be a likely use 
case, but the situation seems to me to go against D's strong 
compile-time guarantees.


More information about the Digitalmars-d mailing list