On 11/12/13 5:17 PM, Oren Ben-Kiki wrote:
I think that introducing two kinds of traits would have non-obvious
implications on the type system

Example?

in addition to saddling us with all the
pains of a single-inheritance types hierarchy system.

I don't think so. In any case.

Also, assuming you do introduce two types of traits, for the reason you
described, making implementation reuse a feature of _only_ one kind of
traits feels very wrong. There should be some way to do reasonable
implementation reuse for the current kind of traits as well.

The general way to do that is to make accessors and mutators in the trait for fields. If we want sugar for accessors and mutators (i.e. properties), then we can cross that bridge later.

You could view the new kind of traits you described as a special case of
what I described. In fact you could say that `pub struct Foo : Bar { ...
}` means exactly `pub struct Foo { reuse Bar::*; ... }`, and also allow
the kind of pointer casts/heterogeneous arrays you are talking about.

How would that enforce the prefix property?

Or, we could move in the direction of anonymous members, which should
also allow for the kind of pointer casts/heterogeneous arrays you
want... These would offer a somewhat different tradeoff than the source
code transformation approach, so you might like them better :-)

No, they don't work for all the use cases. You cannot downcast with anonymous fields. You also cannot mix them with virtual methods in the Go implementation.

Patrick

_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to