On Monday, 11 March 2013 at 10:55:50 UTC, Namespace wrote:
On Sunday, 10 March 2013 at 19:27:01 UTC, Namespace wrote:
But you could prohibit any manipulation of a '&' parameter.
Eg. you could make him 'scope' by default (if 'scope' will
work someday).
A better solution would be to require that a Parameter with '&'
need 'const scope' as storage class.
So the syntax would be:
void foo(in A& a) {
In my opinion, there is then no reason to worry about whether
it is an lvalue or an rvalue. It cannot be changed or
referenced.
This:
void foo(A& a) {
without const scope would cause an error like : "Error: '&'
requires const scope."
AFAIK the syntax 'in ref' was suggested by Kenji but was
rejected for some reasons.
Your point reminds me of the fact that D has no "inline" or
"register" keywords. You probably couldn't pick better experts
than the D compiler builders for deciding whether or not those
two keywords are necessary. I guess there's not a clear solution
to this question, or it would have been settled a while ago.
Maybe it should be called the "performance ref" issue, to
distinguish it from other ref issues, "@safe ref", "auto ref",
etc.