On Wed, Sep 25, 2013 at 6:29 PM, Patrick Walton <pwal...@mozilla.com> wrote:
> On 9/25/13 6:32 AM, Alexander Sun wrote: > >> Embedded anonymous structure? >> > Embedded anonymous structure in Go is good idea, I think. >> > > Not the way Go does it, where you can have method conflicts like C++ > multiple inheritance and it can be surprising which method gets called when > two anonymous fields have a method with the same name. I'm not necessarily > opposed to anonymous fields, but we should tread carefully. Can you say a bit more about that? I thought if two anonymous fields supported a method than it was a conflict and one had to refer to it with the specific field type (foo.TypeOfFirstField.method or foo.TypeOfSecondField.method as opposed to foo.method - the latter would be an error). This sounds pretty reasonable... Since Rust has no implicit traits anywhere, it seems reasonable to require an explicit impl Trait for Container, but allow omitting functions that are obtained from anonymous field(s) - unless one wants to override them, or when they are in conflict between more than one such field. This ensures all type checking is done at declaration rather than in code that uses the traits. It sounds like something along these lines could work in Rust, and it would be very useful...
_______________________________________________ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev