-preview=in might break code
Joseph Rushton Wakeling
joseph.wakeling at webdrake.net
Sat Oct 3 16:46:56 UTC 2020
On Saturday, 3 October 2020 at 16:08:46 UTC, Steven Schveighoffer
wrote:
> This is not any different than calling a function which has a
> reference to the data elsewhere. In other words, it's not
> necessarily the function itself that changes the data, it could
> be changed outside the function. You don't need concurrency to
> do it.
Sure. Concurrency was just one example of how the
implementation-dependent behaviour could arise.
> But it's not impossible to define this:
>
> "when accepting a parameter by `in ref`, one cannot depend on
> the value remaining constant, as other references to the data
> may change it. The compiler can also decide to pass an `in ref`
> parameter by value for optimization reasons, so one cannot
> depend on the parameter changing through a different alias."
OK, but that feels rather like it's imposing a cognitive burden
on the developer as a way to work around the fact that the
feature itself isn't working in an intuitive way.
It feels as unintuitive that a parameter marked `ref` could fail
(in an implementation dependent way) to display reference
semantics, as it does that a non-reference-type parameter _not_
marked `ref` could display them.
More information about the Digitalmars-d
mailing list