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

Moritz Maxeiner via Digitalmars-d digitalmars-d at puremagic.com
Tue Aug 15 02:23:12 PDT 2017


On Tuesday, 15 August 2017 at 07:52:17 UTC, Gary Willoughby wrote:
> 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?

@property changes the typeof result (useful for introspection) 
[1][2]:

---
For the expression typeof(exp) where exp is an @property 
function, the type is the return type of the function, rather 
than the type of the function.
---

---
If the expression is a Property Function, typeof gives its return 
type.
---

[1] https://dlang.org/spec/declaration.html#typeof
[2] https://dlang.org/spec/function.html#property-functions


More information about the Digitalmars-d mailing list