isInputRange as a __traits ?

Jonathan M Davis newsgroup.d at jmdavisprog.com
Sat Oct 7 10:59:02 UTC 2017


On Saturday, October 07, 2017 10:46:05 user1234 via Digitalmars-d wrote:
> On Saturday, 7 October 2017 at 10:40:16 UTC, Jonathan M Davis
>
> wrote:
> > On Saturday, October 07, 2017 10:31:01 user1234 via
> >
> > Digitalmars-d wrote:
> >> Since the compiler has the ability to detect input ranges in
> >> the foreach aggregate that are aggregates implementing the
> >> right primitives, why don't you set the widely used
> >> std.range.isInputRange as a __trait, e.g
> >> __traits(isInputRange, Stuff) ?
> >
> > Why? What would we gain from that?
>
> I've replied in another answer, so again, the idea is to save a
> bit of time spent to compile.

I very much doubt Walter would consider that a good enough reason. And it
would make more sense to try and improve template processing in general than
to try and speed things up by avoiding one template. In general, __traits
does stuff that you can't check with a library, and we _can_ check in the
case of isInputRange. At this point, if something can be done in a library,
it's almost a guarantee that it won't be added to the language. A _really_
strong argument is needed for why something should be in the language rather
than a library if it can be done in a library with the language as-is.

- Jonathan M Davis



More information about the Digitalmars-d mailing list