How to break const

Timon Gehr timon.gehr at gmx.ch
Mon Jun 18 08:50:07 PDT 2012


On 06/18/2012 05:28 PM, Mehrdad wrote:
> On Monday, 18 June 2012 at 15:24:31 UTC, Mehrdad wrote:
>> On Monday, 18 June 2012 at 15:21:36 UTC, Timon Gehr wrote:
>>>> So (**IMHO**) if that's really the case, we should really spend some
>>>> time fixing the /design/ of const before the implementation...
>>>
>>> This is mostly about the design of object initialisation.
>>>
>>>> good idea or no?
>>>
>>> Certainly.
>>
>>
>> My initial instinct would be to require a "const constructor" in order
>> for an object to be const-able, but I'm not sure if that would work
>> correctly or not..
>
> Come to think of it, that would play REALLY nicely with 'scope' -- a
> reference to a non-const object can be escaped from a 'const
> constructor' if and only if the reference is scope!
>
> Bingo! Does that work??

Yes, but it requires proper enforcement of 'scope'.

  - which is undecidable/must be done conservatively
  - code would have to become 'scope correct'



More information about the Digitalmars-d mailing list