Is there any chance to introduce concepts/traits/typeClasses in dlang?
sighoya
sighoya at gmail.com
Sun Dec 15 20:14:45 UTC 2019
To clarify a bit:
Passing a struct containing all the methods in the constraint:
fun(Struct s) if(s.containsMethodsOf(Concept))
is no problem, as the instance (the set of required methods in
the if constraint is delivered by the struct itself when it is
passed as argument to fun), but for the case of type
classes/concepts, the instance is separated from the passed type
and must be implicit passed by the compiler, you need compiler
magic for that akin to Rust or you do it manually akin to the
ugly variant in Scala, even Nim uses magic for this.
More information about the Digitalmars-d
mailing list