Things that keep D from evolving?

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Feb 12 07:12:19 PST 2016


On 2/12/16 9:37 AM, Matt Elkins wrote:
> On Friday, 12 February 2016 at 14:03:05 UTC, Steven Schveighoffer wrote:
>> On 2/10/16 11:51 PM, Matt Elkins wrote:
>>
>>> * The in keyword. This is nice syntactic sugar over having a special
>>> trait in C++ which deduces whether to pass by value or const-reference.
>>> "foo(in bar)" is way more readable than something like
>>> "foo(traits<bar>::fast_param bar)"
>>
>> Hm... in is short for scope const. It is not pass by reference.
>> Perhaps you meant auto ref?
>
> Right...maybe I've been operating under false pretenses, but I was under
> the impression that the compiler was allowed to interpret scope const as
> either "pass by value" or "pass by const reference" freely so long as
> there was no custom post-blit defined? For the purposes of optimization,
> I mean, to avoid needless copying.

Pass by reference and pass by value means different treatment inside the 
function itself, so it can't differ from call to call. It could 
potentially differ based on the type being passed, but I'm unaware of 
such an optimization, and it definitely isn't triggered specifically by 
'in'. 'in' is literally replaced with 'scope const' when it is a storage 
class.

-Steve


More information about the Digitalmars-d-learn mailing list