On 07/24/2015 08:30 PM, Walter Bright wrote:
On 7/24/2015 7:50 AM, jmh530 wrote:
I'm a little confused here. I seem to be of the belief that D's
interfaces can
accomplish virtually the same thing as Rust's traits. In your example,
if the
type you pass to foo also inherits from hasColor, then it shouldn't be
a problem.

As I replied earlier,

"It's a good question. And the answer is, the top level function does
not list every interface used by the call tree. Nested function calls
test at runtime if a particular interface is supported by an object,
using dynamic casting or QueryInterface() calls. It's fundamentally
different from traits and concepts."


This kind of testing for conformance can easily be allowed for traits/concepts at compile time. (E.g. by default, or add a special Meta trait.)

Reply via email to