www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Re: DIP4: Properties

Nick Sabalausky Wrote:

  An alternate usage/definition syntax for properties.
 
 http://prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP4
 
 Note that there are a few parts marked NEED HELP, that could use assistance 
 from someone with more expertise in this than me.
 
 

I'm not sure about combining a property with its backing store - unless the shorthand version is being used, in which case it seems OK. And if the concern is about magic values and new keywords, this version needs neither: class Book { // explicitly declared backing store for author property. private string author_; string author { string() { return author_; } void(string value) { author_ = value; } } // Shorthand property, backing store is generated by compiler. string title { string(); void(string); } } Slightly more verbose, but it's not hideous and doesn't feel alien. John.
Jul 25 2009