RFC: std.*.concept convention
Jakob Ovrum via Digitalmars-d
digitalmars-d at puremagic.com
Wed Feb 11 01:30:12 PST 2015
On Wednesday, 11 February 2015 at 09:11:18 UTC, Jonathan M Davis
wrote:
> We have a whole module full of them - std.traits - so we're
> already using
> that term in Phobos, whereas you won't find the term concepts
> in there
> anywhere. And you seem to be looking for exactly the same thing
> except in
> specific areas - ranges, containers, etc. - rather than having
> all them
> sitting in std.traits.
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. Querying whether or not a type has
"the input range trait" is just plain linguistically awkward.
Using the term concept puts us in line with C++, the biggest -
perhaps the only - competitor D has in the field of template
metaprogramming, which surely aids learning. Indeed, even the
Wikipedia article on C++ concepts[2] seems like a good resource
for understanding the same idea we have in D.
[1] http://www.merriam-webster.com/dictionary/trait
[2] https://en.wikipedia.org/wiki/Concepts_%28C%2B%2B%29
More information about the Digitalmars-d
mailing list