Second CT-Parameter of isRange Predicates

Atila Neves via Digitalmars-d digitalmars-d at
Mon Nov 2 07:33:52 PST 2015

On Monday, 2 November 2015 at 14:33:44 UTC, Andrei Alexandrescu 
> Sent an ICBM its way. -- Andrei

I agree with the ICBM that it definitely doesn't scale. But... 
there should be an easier way to replace arrays of Widget with a 
range. If not, most people (including me on lazy days) will just 
write `Widget[]` and be done with it. I don't know what the best 
solution is.

I'm saying this as someone who's written plenty of D code that 
takes arrays as arguments not because it's right, but because it 
was a lot easier and I didn't want it getting in the way of 
whatever it is I was trying to accomplish.. 90% of my usage of 
`std.array.array` is depressingly enough at the end of an 
algorithm UFCS chain because either I'm passing this to a 
function expecting `T[]` or to a struct that stores `T[]`. It's 
not pretty, performant, or right, but it's easy and I'm lazy.

And that's for writing code. With regards to reading, it's been 
pointed out multiple times that beginners will struggle with 
template contraints on function signatures. It'll be the case 
much more often if every function and struct wanting a range of 
Ts is suddenly `if(isInputRange!R && is(ElementType!R == T))`.


More information about the Digitalmars-d mailing list