Local functions infer attributes?

deadalnix via Digitalmars-d digitalmars-d at puremagic.com
Mon Sep 29 16:25:49 PDT 2014


On Monday, 29 September 2014 at 08:02:45 UTC, Andrei Alexandrescu
wrote:
> I understand. The short answer to this is D cannot do that and 
> we cannot afford to change the language to make it do that.
>
> There are two longer answers.
>

I think this is because ref have several conflated meaning:
   - "I want to mess up with the argument" (à la swap). This is the
meaning it has right now.
   - "Burrowing". Which is the same as previous behavior, except
for classes and delegates, so the whole scope story, as they are
natural "reference types".
   - "Do not copy" aka const ref. This one is for performance
reason. It doesn't really matter if a copy is made or not as the
damn thing is const, but one want to avoid expensive copy when
the thing passed down is fat.

Each of them have their own set of cases where you want and do
not want ref.


More information about the Digitalmars-d mailing list