const attribute makes whole element const?

Jonathan M Davis jmdavisProg at gmx.com
Mon Sep 10 00:45:18 PDT 2012


On Monday, September 10, 2012 09:30:59 Jacob Carlborg wrote:
> On 2012-09-10 09:24, Jonathan M Davis wrote:
> > And it works just fine in D2. It's const that's the problem. In general,
> > if you want a member variable to be "read-only" on a struct, I'd strongly
> > advise using a getter property without a setter property rather than
> > making it const, because const makes it so that stuff like the assignment
> > operator doesn't work.
> Well, in D1 const was a nice shortcut for this.

Whereas in D2, const is both something of fantastic wonder and utter despair. 
:)

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list