@property usage
ketmar via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Dec 8 23:41:25 PST 2014
On Tue, 09 Dec 2014 07:31:20 +0000
Nicholas Londey via Digitalmars-d-learn
<digitalmars-d-learn at puremagic.com> wrote:
> > as this can break some invalid code (the code where people using
> > properties as functions)
>
> Does @property ever make sense for a free floating function? I
> would have thought no but was recently asked to add it if using
> the function with uniform call syntax.
>
> https://github.com/D-Programming-Language/dub/pull/455#discussion_r21430311
when you want to make a function that acts as getter/setter for
delegate callback, for example.
private void delegate () cb;
@property auto myCB () { return cb; }
@property void myCB (void delegate () newcb) {
/* some checks */
cb = newcb;
}
this will work as expected when property enforcement will be fixed --
i.e. you will be able to omit '()' for calling delegate.
alas, this is another thing that is "cosmetic", so PR with property
enforcement will rot on github 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/20141209/db892247/attachment.sig>
More information about the Digitalmars-d-learn
mailing list