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. > >
Have you checked out haXe's syntax for properties? http://haxe.org/ref/properties It's not very sugary, but it doesn't add new keywords and it handles inheritance nicely (to change the prop's behavior in a subclass, just inherit its methods). The other caveat I can think of is that the grammar might need to change a bit before haXe's properties could be used in D, mostly because haXe's declarations are like this: var Identifier : Type; whereas D does decls like so: Type Identifier So perhaps we could have a grammar like this? PropertyDecl: Type Identifier '{' Getter ',' Setter '}' ';' Getter: null default FunctionIdentifier Setter: null default FunctionIdentifier At some point (semantic analysis?) the compiler needs to make sure the functions used in the property have the correct signature. Type foo(); for getter, Type foo(Type); for setter. Something like int foo{default,default}; could be optimized into int foo; though it should otherwise have the semantics of a property and not of a field (e.g. &foo is not allowed or you get a special property struct or somesuch). I also second the importance of whatever Andrei was talking about with respect to properties in some thread a while ago. It was something about potentially needing 3 different accessors for a property due to some inconsistency or potential for pessimization. I forget what exactly. I remember him having difficulty fitting properties into D2's setup for generic algorithms. It would be nice to get that right.
