The liabilities of binding rvalues to ref
Jonathan M Davis
jmdavisProg at gmx.com
Thu May 9 19:10:22 PDT 2013
On Thursday, May 09, 2013 21:56:53 Steven Schveighoffer wrote:
> What about specifying ref at the call site when you know you want the data
> modified?
>
> fix(ref c[i]);
>
> Then if c decides to start returning by value, this is a compiler error.
>
> IMO, fix really should take a pointer. But we want to avoid pointers due
> to the danger of them.
>
> so this is like applying & but keeps it safe.
That would be great except for UFCS. How would you designate the ref when it's
the first argument? And I think that it's worse to have ref optional at the
callsite than to not have it at all.
If it weren't for UFCS, I probably would be in favor of requiring it at the
callsite, but I just don't see how that could work with UFCS. Maybe C# has a
way to deal with that, since it does have some sort of UFCS, and it does
require ref at the callsite (at least from what I understand - I haven't used
C# much)?
- Jonathan M Davis
More information about the Digitalmars-d
mailing list