class invariants and property declarations
Jonathan M Davis
jmdavisProg at gmx.com
Wed Feb 16 11:04:58 PST 2011
On Wednesday, February 16, 2011 09:47:32 Jesse Phillips wrote:
> Dmitry Olshansky Wrote:
> > Now to properties, this is actually shouldn't be allowed:
> > @property int hours;
> >
> > @property is a annotation applied to functions (getter/setter), to allow
calling it with omitted () and a natural assign syntax like this:
> Why shouldn't it be allowed? While it provides no benefit it does document
> that it is a property.
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
More information about the Digitalmars-d-learn
mailing list