RFC: Implementation of binary assignment operators (e.g s.x += 2) for @property functions

Johannes Pfau via Digitalmars-d digitalmars-d at puremagic.com
Tue Aug 15 01:01:36 PDT 2017


Am Tue, 15 Aug 2017 07:52:17 +0000
schrieb Gary Willoughby <dev at nomad.so>:

> On Tuesday, 15 August 2017 at 03:53:44 UTC, Michael V. Franklin 
> wrote:
> > An implementation of binary assignment operators for @property 
> > functions has been submitted to the DMD pull request queue at 
> > https://github.com/dlang/dmd/pull/7079.  It addresses the 
> > following issues:
> >
> > Issue 8006 - Implement proper in-place-modification for 
> > properties
> > https://issues.dlang.org/show_bug.cgi?id=8006  
> 
> I thought @property's behaviour had been removed from the 
> language and even though the attribute remains, it doesn't 
> actually do anything?
> 
> 

You're probably thinking of the special optional/non-optional
parenthesis rules and the -property compiler switch which was removed.

@property should still be used according to the style guide:
https://dlang.org/dstyle.html
and as far as I can tell it's heavily used in phobos.

Properties behave more like field variables in some traits:
http://dlang.org/spec/traits.html
https://dlang.org/phobos/std_traits.html

But I think that's the only relevant difference between properties and
normal functions right now.

-- Johannes



More information about the Digitalmars-d mailing list