On Tue, 09 Dec 2014 07:31:20 +0000 Nicholas Londey via Digitalmars-d-learn <digitalmars-d-learn@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.
signature.asc
Description: PGP signature