How to disable assigning a value to a property?

Steven Schveighoffer schveiguy at gmail.com
Tue Jul 6 14:58:22 UTC 2021


On 7/6/21 9:27 AM, Jack Applegame wrote:
> On Tuesday, 6 July 2021 at 12:33:20 UTC, Adam D Ruppe wrote:
>> The language always allows `a = b;` to be rewritten as `a(b);`.
> 
> And that's sad. It should happen for properties only.
> 

Yes, I lament that there is no way to control how people call your 
function. It can result in surprising things, and it means as a library 
designer you have to consider this usage when picking names.

There are a few "draft" DIP proposals (under the old DIP system) here: 
https://wiki.dlang.org/DIPs

But I think the time of being able to make such a disruptive change has 
passed. For better or worse we have the half-implemented near-useless 
meaning of `@property`, and basically it's unneeded.

-Steve


More information about the Digitalmars-d-learn mailing list