How to break const

deadalnix deadalnix at gmail.com
Mon Jun 18 08:51:46 PDT 2012


Le 18/06/2012 17:50, Timon Gehr a écrit :
> 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'
>

Come on, what can't we infers qualifiers ?


More information about the Digitalmars-d mailing list