class invariants and property declarations

Jesse Phillips jessekphillips+D at gmail.com
Thu Feb 17 10:39:20 PST 2011


Jonathan M Davis Wrote:

> Except that @property is for _functions_. You mark a function with @property so 
> that it _acts_ like a variable. @property on a variable is _meaningless_. It 
> would be like marking a variable nothrow. It makes no sense. Neither should be 
> legal. The fact that a member variable is public makes it a property. @property 
> on a member variable makes no sense.
> 
> - Jonathan M Davis

class Foo {
    @property {
           int min;
           int hour() { return _hour;}
          ...
    }
}

I agree that useless markings should usually be disallowed, but for me there is visual cues that @property provides and if I'm declaring a number of public fields/functions I'd want the present them in a similar manner.


More information about the Digitalmars-d-learn mailing list