Asking a const-related fix [Was: Re: DMD workforce contribution]

Gor Gyolchanyan gor.f.gyolchanyan at gmail.com
Mon Nov 7 08:13:49 PST 2011


I think the problem arises because in order for this to be fully safe,
the constructor needs to be called before the object is allocated (by
making an always-writable temporary) because otherwise the members
could end up in ROM and physically immutable to the constructor.

On Mon, Nov 7, 2011 at 8:08 PM, Timon Gehr <timon.gehr at gmx.ch> wrote:
> On 11/07/2011 11:57 AM, Jonathan M Davis wrote:
>>
>> That would be altering aa, which isn't legal. const variables can be
>> initialized but _can't_ be assigned to. If you want to do something
>> fancier
>> than a simple initialization, you're going to need to create another array
>> which you do everything to and _then_ initialize the const array with
>> that.
>> The errors that you're running into are completely by design.
>>
>
> What bearophile is asking for is to treat those cases like an initialization
> (what they, in fact, are) rather than like an assignment.
>


More information about the Digitalmars-d mailing list