-preview=in might break code

tsbockman thomas.bockman at gmail.com
Fri Oct 2 19:54:35 UTC 2020


On Friday, 2 October 2020 at 14:48:18 UTC, Steven Schveighoffer 
wrote:
> I think in should always mean ref. If you want to pass not by 
> ref, use const.

Please do not kill this optimization. There is currently no other 
reasonable way available in the D language to express the idea of 
"pass by reference or by value, whichever is faster". But, there 
is an easy way to require that a parameter always be passed in a 
specific way: just don't use `in` and use `scope const` or `scope 
const ref` directly.

Implementing this optimization manually is quite painful in D; 
the possibilities are complex and very ugly, and require detailed 
knowledge of the platform's ABI to implement correctly in the 
general case.

D is a systems programming language, and should not kill useful 
features just because they have potential pitfalls. At most, 
problematic features may be blocked by @safe/linters/style 
guides, but please don't remove them entirely.


More information about the Digitalmars-d mailing list