Little demo of allowing basic types to implement interfaces. Was in D.annouce

Dicebot public at dicebot.lv
Wed Sep 4 02:49:11 PDT 2013


It does not exist and often (re)implemented by different people 
here and there.

There still few issues that do not make it vastly more superior 
than existing `isInputRange!T` and friends - I guess this is why 
no one bothered submitting pull requests to the Phobos in the end.

1) You have already stumbled upon this. The fact that templates 
are evaluated at declaration scope + UFCS makes it almost useless 
as generic template. `std.range` imports `std.array` workaround 
this for most common case but this remain unsolved problem in 
general.

2) You can't check for behavior with it, only for signatures (and 
may be subject to any type comparison quirks)

3) It still does not give you the power of Go interfaces / Rust 
traits - one can't use interface parameter type to pass in a 
struct that matches it (via automatically generated fat pointer)


More information about the Digitalmars-d-learn mailing list