On 10/23/12 5:46 AM, Julien Blanc wrote:
Lucian Branescu a écrit :
Something like this
http://pcwalton.github.com/blog/2012/08/08/a-gentle-introduction-to-traits-in-rust/

Very nice introduction. The only question that arises for me (coming from
c++ ground and comparing this to c++ templates) is why trait
implementation is made explicit ?

Is it a design decision or a current compiler limitation ? I guess the
compiler could not too difficultly be made smart enough to determine from
its actual interface if a type conforms to a trait. Code generation may be
more a problem, though…

The problem is that you wouldn't know which trait a method belongs to. There can be multiple traits that both define a method with the same name and signature, say, `foo`.

In general it's hard to prevent this in the presence of separate compilation. Suppose we have library A that defines a trait with a method `foo` and, separately, there's a library B that defines a different trait with a method named `foo`. Now you want to link A and B together...

Patrick

_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to