Ranges: is it ok if front is a data member?

Joseph Rushton Wakeling joseph.wakeling at webdrake.net
Thu Dec 12 14:17:04 PST 2013


On 12/12/13 22:55, Ali Çehreli wrote:
> That condition is what makes a slice an OutputRange, which causes the super
> confusing state of "output range losing elements after put'ting": :)
>
> import std.range;
>
> void main()
> {
>      auto s = [ 1, 2, 3 ];
>      s.put(10);
>      assert(s.length == 2); // PASSES! :p
> }

Ouch!!

I see why it happens, but I really, really don't like that.  Isn't there a case 
here for an override to put specifically for arrays?  Or are there some benefits 
to it working like this?



More information about the Digitalmars-d-learn mailing list