Protocols vs Concepts?
Jacob Carlborg
doob at me.com
Wed Nov 20 23:50:50 PST 2013
On 2013-11-21 00:27, Shammah Chancellor wrote:
> I just watched this talk from the goto conference by Walter Bright
> (https://www.youtube.com/watch?v=cQkBOCo8UrE) and he makes reference to
> "concepts." However, they look almost identical to Protocols in
> Smalltalk -- something which I would very much like to see in D.
>
> It basically works much like an interface, but instead of declaring it,
> you check the type to see if it defines the appropriate methods.
>
> In fact -- I believe this could be implemented today with __traits and
> static foreach to simply check to see if a type conforms to a protocol
> at compile time.
>
> implementsProtocol!( R, InputRange!(int) );
>
> where InputRange!() could just be a templated interface.
>
> Having this in phobos would be really helpful! If there is interest in
> this, I'll write a template up and submit it to phobos.
D you mean something like this:
http://forum.dlang.org/thread/l6jgha$1elj$1@digitalmars.com#post-l6kdvj:2428tr:241:40digitalmars.com
I would like to have that.
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list