-preview=in might break code
Steven Schveighoffer
schveiguy at gmail.com
Sat Oct 3 14:49:03 UTC 2020
On 10/3/20 10:10 AM, Steven Schveighoffer wrote:
> Another option is to tag an `in` value as "I'm OK if this is passed by
> reference". like `in ref` or something (that still binds to rvalues).
> Then an optimization can say "actually, I'm going to pass this by
> value", and nobody cares. This is different in that you have to
> *declare* you're ok with a reference, not the other way around.
Thinking about this more, it seems my major problem is that `in` as it
is without the switch is not a reference.
`in ref` is a reference, and it's OK if we make this not a reference in
practice, because it's const. And code that takes something via `in ref`
can already expect possible changes via other references, but should be
OK if it doesn't change also.
Can we just change -preview=in so it affects `in ref` instead of `in`?
-Steve
More information about the Digitalmars-d
mailing list