On Thu, 23 May 2013 11:14:47 -0400, Steven Schveighoffer <[email protected]> wrote:

On Thu, 23 May 2013 11:07:16 -0400, Dicebot <[email protected]> wrote:

On Thursday, 23 May 2013 at 14:58:01 UTC, Steven Schveighoffer wrote:
Seems like const qualifier for members is simply ignored inside the ctor, it should only be ignored until it is set, or until it is used.

I am quite sure I have seen it (mutability of immutable in constructor) guaranteed either by spec or TDPL. Don't have TDPL with me right now, need to check later.

I did check, though not thoroughly. I think it only talks about actual immutable constructors (that is, initializing a fully immutable-qualified instance). It doesn't really talk about immutable members.

And for immutable constructors, the rule seems to be that you can assign fields as many times as you want, but you cannot read them, or call any methods.

I think whatever rules are used, they should be consistent for immutable/const members as well.

Actually, this is a bad idea.  TDPL may need to be invalidated here.

If this was followed, then normal mutable ctors would become as limited as immutable ctors because they would have to follow the same rules (no calling other methods).

I still think it should be consistent between both things (immutable ctors and initializing immutable data).

I'll post a thread on standard NG.

-Steve

Reply via email to