-preview=in might break code
Ola Fosheim Grøstad
ola.fosheim.grostad at gmail.com
Fri Oct 2 19:57:15 UTC 2020
On Friday, 2 October 2020 at 19:37:43 UTC, Steven Schveighoffer
wrote:
> On 10/2/20 3:20 PM, Ola Fosheim Grøstad wrote:
> That's just the thing. The -preview=in feature does not define
> whether the parameter is pass by value or by reference. It
> says, "up to the compiler".
Yes, I agree with you. The language spec should stick to the
proper theoretical concept, e.g. pass by reference. It could also
require no-aliasing of in-parameters and define aliasing as
undefined behaviour that the compiler may or may not detect.
Disallowing aliasing can give better codegen (faster).
Then it could put in a footnote that some compilers optimize such
and such as values in registers ( for those that read
disassembled code ), but it should be no more than a footnote.
> I should be able to expect one behavior, and then if the
> compiler can pass the parameter differently but I can't tell,
> then that's fine. But this isn't that.
True.
More information about the Digitalmars-d
mailing list