dmd 2.063 beta 5

Steven Schveighoffer schveiguy at yahoo.com
Thu May 23 08:29:23 PDT 2013


On Thu, 23 May 2013 11:14:47 -0400, Steven Schveighoffer  
<schveiguy at yahoo.com> wrote:

> On Thu, 23 May 2013 11:07:16 -0400, Dicebot <m.strashun at gmail.com> 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


More information about the Digitalmars-d-announce mailing list