-preview=in might break code

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Sat Oct 3 13:10:28 UTC 2020


On Saturday, 3 October 2020 at 11:04:48 UTC, Timon Gehr wrote:
> There's a difference between "the behavior may be either A or 
> B" and "the behavior may be anything you like"...

And just to be clear on this: the example Steven gave showed code 
that should be defined to be outside of the language. It is not 
code that anyone would want to pass the compilation stage if the 
compiler could be made smart enough to detect it.

The moment you say the undesirable behaviour is within the 
language, you have effectively made the example valid and thus an 
improved compiler cannot reject it. If it is within the language 
an improved compiler would be a breaking change.

The value-implementation of reference passing is different, 
because such implementation specific behaviour may be desirable! 
But the code Steven provided was not desirable to allow as a 
"valid text" in the language.

(A language spec can provide details of how the runtime should 
behave when the compiler fails to detect whether code is within 
the language or not. Then you just label "undefined behaviour" as 
"illegal constructs", but it is essence the same thing).



More information about the Digitalmars-d mailing list