The point of const, scope, and other attributes

Tejas notrealemail at gmail.com
Sat May 14 00:04:26 UTC 2022


On Friday, 13 May 2022 at 18:43:11 UTC, H. S. Teoh wrote:
> On Fri, May 13, 2022 at 06:25:22PM +0000, Fry via Digitalmars-d 
> wrote:
>> > > [...]
> [...]
>> [...]
>
> Yeah, more than one long-time D user (including myself) has 
> come to this conclusion. In my own experience, const is mainly 
> useful at the lowest levels of code (strings, leaf-node modules 
> that operate on some self-contained data structure that doesn't 
> depend on anything else). Once you get to a high enough level 
> of abstraction, it starts getting in your way and becomes far 
> too much more work than the benefits it offers; it's just not 
> worth the trouble.  So these days I don't really bother with 
> const, except in small pockets of leaf-node code.
>
>
>> [...]
> [...]
>
> I thought `auto ref` was supposed to do this?  But I recall 
> people hating `auto ref` for various reasons...
>
>
> T

Both `auto ref` and `in` make a copy if it's an rvalue.

Idk why people hate `auto ref` though... most likely the fact 
that one might have to do `__traits(isRef, symbol)` anyways for 
some edge cases


More information about the Digitalmars-d mailing list