On Thursday, 7 February 2013 at 14:43:38 UTC, Steven Schveighoffer wrote:
On Thu, 07 Feb 2013 01:06:34 -0500, Walter Bright <[email protected]> wrote:


The only time (now) that you can take the address of function return value is if that is a return by ref. So, if taking the address of a ref is disallowed, then the syntax is no longer ambiguous.

Thinking about this, I don't know that I like the idea of disallowing taking the address of ref.

One major usage of taking the address of ref returns is the opIndex operator:

int *ptr = &arr[0];

Or, more generally, the front property of a range:

int *ptr = &arr.front;

What I am concerned about is that this is not going to have the desired effect. Instead of grudgingly switching to a new style of coding, people will simply return pointers instead of ref.


Exactly.

Reply via email to