DIP 1016--ref T accepts r-values--Formal Assessment
noone at nowhere.com
Thu Jan 24 20:01:45 UTC 2019
On Thursday, 24 January 2019 at 09:49:14 UTC, Manu wrote:
> We discussed and concluded that one mechanism to mitigate this
> was already readily available, and it's just that 'out' gains a
> greater sense of identity (which is actually a positive
> side-effect if
> you ask me!).
> You have a stronger motivation to use 'out' appropriately,
> because it
> can issue compile errors if you accidentally supply an rvalue.
`out` with current semantics cannot be used as drop-in
replacement for shared in-/output ref params, as `out` params are
default-initialized on entry. Ignoring backwards compatibility
for a second, I think getting rid of that would actually be
beneficial (most args are probably already default-initialized by
the callee in the line above the call...) - and I'd prefer an
explicitly required `out` at the call site (C# style), to make
the side effect clearly visible.
I'd have otherwise proposed a `@noRVal` param UDA, but redefining
`out` is too tempting indeed. ;)
More information about the Digitalmars-d-announce