const as default for variables
deadalnix via Digitalmars-d
digitalmars-d at puremagic.com
Mon Mar 16 12:51:59 PDT 2015
On Monday, 16 March 2015 at 14:40:51 UTC, Zach the Mystic wrote:
> On Sunday, 15 March 2015 at 20:09:56 UTC, deadalnix wrote:
>> On Sunday, 15 March 2015 at 07:44:50 UTC, Walter Bright wrote:
>>> "const ref" can tell the optimizer that that path for a ref
>>> counted object cannot alter its ref count.
>>
>> That is not clear why. const ref is supposed to protect
>> against escaping when ref does not ?
>
> There are two cases here. One is when the reference is copied
> to new variable, which would actually break const because the
> reference count of the original data would have to be
> incremented (which is a separate issue).
I think we should provide library solution for this kind of
things.
More information about the Digitalmars-d
mailing list