RFC: std.*.concept convention

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Wed Feb 11 13:25:50 PST 2015


On Wednesday, February 11, 2015 09:30:12 Jakob Ovrum via Digitalmars-d wrote:
> There is a difference between a concept and a trait. A concept
> can be composed of multiple traits. In the context of a concept,
> these traits could be called primitives.
>
> Saying that `isInputRange` is a trait is just clumsy. It's a
> checker template. You could rephrase it and say that it's a
> checker template for the input range trait; but it doesn't check
> for a single distinguishing quality[1], it checks if all of a
> number of traits are present.

_Every_ trait is just a "checker template" - be it isInputRange,
isDynamicArray, isInteger, isSomeString, hasLength, etc. In all cases,
they're checking something about a type. I don't see anything different
about isInputRange from hasLength or isPointer except for what they're
checking for, and that's different for every trait. And some of the traits
in std.traits are quite complicated, so it's not like the ones in there are
simple, and the ones elsewhere in Phobos are complex.

> Querying whether or not a type has
> "the input range trait" is just plain linguistically awkward.

I don't see why you'd even need to talk that way. It's not a question of
whether something has the input range trait or whether something has the
input range concept. It's a question of whether something _is_ an input
range, and the trait isInputRange checks that.

- Jonathan M Davis



More information about the Digitalmars-d mailing list