Article: Why Const Sucks

SimonN eiderdaus at gmail.com
Mon Mar 5 13:53:21 UTC 2018


On Monday, 5 March 2018 at 10:57:35 UTC, Jonathan M Davis wrote:
> Here's something I wrote up on const:

Excellent read! I enjoyed the history of proposed solutions.

I've run into the trouble with annotated opEquals in classes 
several times. I believe an empty/nonexistant Object class is the 
correct solution, together with templates. If it breaks tricky 
opEquals-overriding usercode, then so be it. The const trouble is 
merely a symptom here, the real problem is Object.

In structs, all const members feel alien, they preventing all 
copying. This seems far harder to solve.

-- Simon


More information about the Digitalmars-d-announce mailing list