const as default for variables
Zach the Mystic via Digitalmars-d
digitalmars-d at puremagic.com
Tue Mar 17 15:25:29 PDT 2015
On Tuesday, 17 March 2015 at 19:53:14 UTC, deadalnix wrote:
> On Tuesday, 17 March 2015 at 13:55:36 UTC, Dejan Lekic wrote:
>> I definitely think this is a good idea. And if someone wants
>> mutable variable, we simply use proposed 'var' storage class.
>>
>> Brilliant!
>
> This is going to break pretty much all the code that use auto.
>
> The benefice for the compiler is hypothetical. Walter is right
> when mentioning that is can remove some refcount boilerplate,
> which is right but, we have no idea how much, and how good the
> compiler would be at recognizing them. With existing languag
> feature, the compiler CANNOT leverage this change for
> optimization.
The real devil against safe reference counting is in the
assignment operators, when they do destructive moves. I think
those have to be the focus of any effort here.
I'm trying to imagine a parameter attribute `@destroy`, for
example, indicating that its reference may get destroyed. Not
sure if it will work, or even help, but it's a start.
More information about the Digitalmars-d
mailing list