On 06/23/2015 12:40 AM, Andrei Alexandrescu wrote:
On 6/22/15 3:06 PM, Timon Gehr wrote:
On 06/22/2015 06:11 AM, Andrei Alexandrescu wrote:
Walter and I discussed what auto ref for templates should look like and
reached the conclusion that an approach based on lowering would be best.
I added a proposed lowering to
https://github.com/D-Programming-Language/dmd/pull/4717.

Andrei

"@WalterBright auto ref for templates and non-templates do different
things by necessity. ..."

The proposed lowering also works for template functions.

"... This is not an issue."

Yes it is. Walter is right.

For templates, auto ref generates two copies of the function. Inside,
which was generated can be interrogated by using is(param == ref). For
non-templates, only one copy of the function is generated. Using
is(param == ref) inside should be an error.

The two mechanisms bear many similarities and some differences, too.
...

There is no reason to prevent templates from using the mechanism that generates only one copy. The two mechanisms shouldn't share the same syntax, because then there is no way to tell them apart for template functions.

Reply via email to