Rant after trying Rust a bit

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Sat Jul 25 05:52:16 PDT 2015


On 7/24/15 2:05 AM, H. S. Teoh via Digitalmars-d wrote:
> Well, this is where the whole idea of Concepts comes from. Rather than
> specify the nitty-gritty of exactly which operations the type must
> support, you introduce an abstraction called a Concept, which basically
> is a group of related traits that a type must satisfy. You can think of
> it as a prototypical "type" that supports all the required operations.
>
> For example, an input range would be a Concept that supports the
> operations .front, .empty, and .popFront. A forward range would be a
> larger Concept derived from the input range Concept, that adds the
> operation .save.
>
> Your range functions don't have to specify explicitly that "type T must
> have methods called .empty, .front, .popFront", they simply say "type T
> must conform to the InputRange Concept".

As I argued in "Generic Programming Must Go", this does work on 
scarce-vocabulary domain. The moment you start talking about ranges that 
may or may not support cross-cutting primitives, it all comes unglued. 
-- Andrei


More information about the Digitalmars-d mailing list