Re: [rust-dev] Can traits define instance vars?
Hi Oliver, Glad you're liking Rust so far :) Currently traits can only have methods (functions that have a self parameter) and associated functions (functions without a self parameter). There's a proposal to add inheritance on structs to Rust, which would allow a trait to extend a struct and gain access to its fields. This (very) long mailing list threadhttps://mail.mozilla.org/pipermail/rust-dev/2013-November/006465.htmlis the most recent discussion I'm aware of. There are a couple ideas in there about how to get similar behavior using just existing Rust constructs (I'm still biased towards the solution I gave in there). I'm not aware of any plans for a rust-users forum. Maybe spinning a rust-users mailing list off from rust-dev would make sense? We already did a similar thing with our IRC channels. Eric On Mon, Dec 2, 2013 at 2:12 AM, jeti...@web.de wrote: Hello, I lately had a look at Rust and really liked it in many ways. Rust has really everything I'm missing in Go ;-). There is something about traits I would like to ask I can't see from the manual. Question is whether you define instance variables in traits or abstract variables like Ceylon and Kotlin have them. Abstract traits vars in Kotlin look like this (sample code taken from here: http://blog.jetbrains.com/kotlin/2011/08/multiple-inheritance-part-2-possible-directions ): trait Trait { val property : Int // abstract fun foo() { print(property) } } class C() : Trait { override val property : Int = 239 } Can something like this be done for traits in Rust as well? Then I would like to ask whether you are planning to have some Rust forum for users. The question I was asking in this mail on rust-dev really doesn't belong into the dev mailing list. So something like a google Rust-users newsgroup would be a good thing to have. I know several people that are interested in Rush. Think it would give Rust a little push if a Rust-user forum would exist. Regards, Oliver ___ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev ___ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev
Re: [rust-dev] Can traits define instance vars?
On 12/02/2013 11:12 AM, jeti...@web.de wrote: Hello, I lately had a look at Rust and really liked it in many ways. Rust has really everything I'm missing in Go ;-). There is something about traits I would like to ask I can't see from the manual. Question is whether you define instance variables in traits or abstract variables like Ceylon and Kotlin have them. Abstract traits vars in Kotlin look like this (sample code taken from here: http://blog.jetbrains.com/kotlin/2011/08/multiple-inheritance-part-2-possible-directions): trait Trait { val property : Int // abstract fun foo() { print(property) } } class C() : Trait { override val property : Int = 239 } Can something like this be done for traits in Rust as well? Then I would like to ask whether you are planning to have some Rust forum for users. The question I was asking in this mail on rust-dev really doesn't belong into the dev mailing list. So something like a google Rust-users newsgroup would be a good thing to have. I know several people that are interested in Rush. Think it would give Rust a little push if a Rust-user forum would exist. Regards, Oliver I would love it. Of the 2 cases of custom traits I have defined do far in Rust, one is only about 3 instance vars (thus ends up empty), the other about 1 vars and 1 method (thus holds only the latter). I find traits weird without vars, and annoying since the compiler does not know that the conforming types _do_ have such vars (thus one is forced to down-cast for no other reason that vars are absent from the trait def, or do i miss a point?). This, in addition to control of actual conformity of types to declared traits. Denis ___ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev