Properties don't work as expected

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jul 5 06:36:17 PDT 2016


On 7/5/16 6:52 AM, zodd wrote:

> Is there a chance, that this weird behavior will be fixed in the near
> future? What can I do to help fix it?

Properties do not support read-modify-write operations. You can return a 
reference, or return a wrapper type to enable the operations you want.

D does not support any of the normally-expected property rewrites that 
many languages do.

For example: a.b.c = 5 where b is a property may not do what you expect.

It has been suggested in the past to have this behavior, but I doubt it 
will happen. It's possible to write such mechanisms as a library, but 
I've never seen someone do it.

-Steve


More information about the Digitalmars-d-learn mailing list