Well, there are many times I'd rather have 'this' passed by value for 
efficiency!

Const ref would fit the bill nicely, if it didn't affect the type.


What would be interesting is if there was a way to say "this won't change in 
this function", and then the compiler could choose to pass by ref or value 
depending on which was more efficient, while still enforcing the property that 
the value doesn't change.

Hm.. could there be a library solution?


-Steve




>________________________________
> From: Sean Kelly <[email protected]>
>To: Steve Schveighoffer <[email protected]>; Discuss the dmd beta releases 
>for D <[email protected]> 
>Sent: Monday, April 16, 2012 2:31 PM
>Subject: Re: [dmd-beta] rvalue references
> 
>On Apr 16, 2012, at 6:32 AM, Steve Schveighoffer wrote:
>> 
>> Regardless of the solution, I think we need to designate two different 
>> situations:
>> 
>> 1. I want to pass this by reference because it's more efficient
>> 2. I want to pass this by reference because I want to change it
>
>Ideally, no one should ever specify "ref" simply for efficiency.  The 
>programmer should choose semantics for logical reasons, and leave optimization 
>up to the compiler.  That may still not be practical however.
>
>
>
_______________________________________________
dmd-beta mailing list
[email protected]
http://lists.puremagic.com/mailman/listinfo/dmd-beta

Reply via email to