auto ref is on the docket
Jonathan M Davis via Digitalmars-d
digitalmars-d at puremagic.com
Tue Jun 23 09:27:31 PDT 2015
On Tuesday, 23 June 2015 at 13:52:19 UTC, Daniel N wrote:
> On Tuesday, 23 June 2015 at 11:03:10 UTC, Jonathan M Davis
> wrote:
>> Which does not generally work in D. It can in some cases, but
>> const is so restrictive in D that you simply cannot use it
>> just because you don't intend to mutate a variable. Too many
>> types won't work with const, and many types _can't_ work with
>> const. const has its uses, but you have to be careful with it,
>> and in the general case, that means that you can't put it on
>> function parameters just to indicate that the function
>> argument is not going to mutated.
>>
>> - Jonathan M Davis
>
> Thus the solution cannot require const.
>
> auto is worse because, if you later decide you need to add a
> template parameter then the meaning is changed and you get a
> _hidden_ performance issue.
And how does it introduce a hidden performance issue. You'd end
up with some template bloat, but that's it, and that's just going
to increase the memory footprint of your program slightly, which
isn't generally going to be a performance issue. It's just going
to make your program slightly larger.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list