Re: [rust-dev] Getter and setters

2012-07-22 Thread Patrick Walton
Oh, and also forbidding public fields would break pattern matching, unless we came up with some way to overload *that* a la Scala's "unapply". Patrick ___ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev

Re: [rust-dev] Getter and setters

2012-07-22 Thread Patrick Walton
To follow up, in order to get rid of public fields, we'd have to require all field names to be module-private and have the automatic "public accessor and mutator" syntax generate "impl" declarations next to the class. If the field was immutable, it'd have to generate two implementations, one fo

Re: [rust-dev] Getter and setters

2012-07-22 Thread Patrick Walton
On 7/22/12 11:31 AM, Masklinn wrote: On 2012-07-22, at 20:18 , Patrick Walton wrote: That said personally I think there is no point having properties and prop functions unless you can have "private" fields which im not sure Rust can do as you need a "this" pointer which then makes you an OO la

Re: [rust-dev] Getter and setters

2012-07-22 Thread Masklinn
On 2012-07-22, at 20:18 , Patrick Walton wrote: >> That said personally I think there is no point having properties and >> prop functions unless you can have "private" fields which im not sure >> Rust can do as you need a "this" pointer which then makes you an OO >> language . > > Classes (now s

Re: [rust-dev] Getter and setters

2012-07-22 Thread Patrick Walton
On 7/22/12 9:52 AM, Bennie Kloosteman wrote: - Your spending a lot of time making Rust brief yet hear you are writing a function for every field.. that's a lot of brain dead code.. When C# started , first they thought properties were a nice to have but later properties became a representation tha

Re: [rust-dev] Getter and setters

2012-07-22 Thread Bennie Kloosteman
> > As for getters and setters, I've thought about them, but I'm really > inclined to say YAGNI here. C# added them, and they actually accrued a lot > of complexity over time (autogenerated getters and setters, etc). You can > pretty easily make a function opts() and set_opts(). Our complexity budg

Re: [rust-dev] Getter and setters

2012-07-22 Thread Patrick Walton
On 7/21/12 11:54 AM, David Bruant wrote: What do you think? First off, there are several problems with this code, the most obvious of which is that it's an awkwardly newtype'd record and not a struct. Fixing that should make the code look a lot less awkward. As for getters and setters, I've

Re: [rust-dev] Getter and setters

2012-07-22 Thread Bennie Kloosteman
There are no real cons..it gets compiled out. The big pros to me are put a break point on them and access control ( which can be different between read and write) . However I'm not sure how to do private field / public property ( get function) in Rust . Ben On Sun, Jul 22, 2012 at 7:15 PM, Davi

Re: [rust-dev] Getter and setters

2012-07-22 Thread David Bruant
Le 22/07/2012 12:56, Matthieu Monrocq a écrit : > Hi, > > It sounds to me like /properties/ => > http://en.wikipedia.org/wiki/Property_%28programming%29 > > /A *property*, in some object-oriented > programming > languages

Re: [rust-dev] Getter and setters

2012-07-22 Thread Matthieu Monrocq
Hi, It sounds to me like *properties* => http://en.wikipedia.org/wiki/Property_%28programming%29 *A property, in some object-oriented programming languages , is a special sort of class

[rust-dev] Getter and setters

2012-07-21 Thread David Bruant
Hi, I was looking at the task.rs code [1] and I noticed the getter and setter for "opts" couldn't help thinking that it is boilerplate code. Comments removed, the incriminated code looks like this: enum builder { builder_({ mut opts: task_opts, mut gen_body: fn