-preview=in might break code

Joseph Rushton Wakeling joseph.wakeling at webdrake.net
Sun Oct 4 09:15:36 UTC 2020


On Saturday, 3 October 2020 at 21:36:00 UTC, Mathias LANG wrote:
> A platform dependent change of lvalue-ness is trivial to craft 
> using only `auto ref`:
> ```
> void foo () (auto ref size_t value)
> {
>     pragma(msg, __traits(isRef, value));
> }
> auto ref size_t platform (uint* param) { return *param; }
> extern(C) void main ()
> {
>     uint value;
>     foo(platform(&value));
> }
> ```
>
> Tested on Linux64:
> ```
> % dmd -betterC -run previn.d
> false
> % dmd -betterC -m32 -run previn.d
> true
> ```

Platform-dependent, yes -- but the behavioural difference here 
can be 100% anticipated from the language rules (and hence, from 
the code), no?

Isn't the issue with `-preview="in"` as currently implemented 
that _there is no way_ for the reader of the code to anticipate 
when ref will be used and when not?


More information about the Digitalmars-d mailing list