@property usage

ketmar via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Dec 6 16:46:31 PST 2014


On Sat, 06 Dec 2014 15:23:10 -0800
Jonathan M Davis via Digitalmars-d-learn
<digitalmars-d-learn at puremagic.com> wrote:

> 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.
we all waiting for property enforcement fixes (which i already
integrated, heh), so delegate properties can be used as propeties,
omiting the annoying '()'.

as this can break some invalid code (the code where people using
properties as functions) i assume that we'll live with half-backed
properties forever.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20141207/fea8209f/attachment.sig>


More information about the Digitalmars-d-learn mailing list