@property usage

Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Dec 6 15:23:10 PST 2014


On Thursday, December 04, 2014 10:21:10 uri via Digitalmars-d-learn wrote:
> Hi All,
>
> Do you guys use @property much, or is it largely ignored/avoided?

@property is used rather freuently - e.g. some of the functions in the range
API are required to be properties. Typically, @property is used when you'd
use a getter or setter in another language (or when you need to emulate a
variable). Using get* or set* would generally not be considered idiomatic D
and is not typically done. @property functions are used instead.

Now, because the parens are optional on functions with no arguments, there
are plenty of cases where functions are called without parens when they're
not properties, but property functions are quite common.

- Jonathan M Davis



More information about the Digitalmars-d-learn mailing list