-preview=in might break code

Steven Schveighoffer schveiguy at gmail.com
Fri Oct 2 19:03:52 UTC 2020


On 10/2/20 2:33 PM, Ola Fosheim Grøstad wrote:
> On Friday, 2 October 2020 at 17:31:06 UTC, Steven Schveighoffer wrote:
>> Yes, the problem is the "sometimes ref". Because ref changes the 
>> semantics.
>>
>> I read it as, in means by ref, unless the compiler can prove it's the 
>> same to pass by value, and that is more efficient. But if it's for 
>> *optimization*, it shouldn't change the effective semantics. The 
>> optimizer should be invisible.
>>
>> In practice, I don't think the compiler can prove that.
> 
> A good backend most certainly can? This ought to be a pure backend issue 
> and not affect the fontend at all if the separation front/back is as it 
> should be.

How does the compiler prove that passing by value or by reference is not 
going to affect the resulting code? I mean, it could potentially say, 
there are no references in all the mutable parameters, and so I can pass 
by value. But that's kind of a wide net.

> 
> Calling conventions do not belong in a language spec...
> 

You mean by ref or by value isn't part of the language spec? I don't 
understand the point.

-Steve



More information about the Digitalmars-d mailing list