On Monday, 22 June 2015 at 04:11:41 UTC, 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.
So, you're basically suggesting that have an auto ref parameter
on a non-templated function basically does the combinatorial
explosion of function definitions that you get with templated
functions except that all of the combinations are instantiated
(the one difference then being that all of the overloads except
the one with all refs would just be wrappers calling the one with
all refs)? That doesn't sound particularly desirable me. It's
better than writing all of those wrappers by hand, but that's
still likely to be a fair bit of code bloat if you're using auto
ref parameters much - and if the folks coming from C++ who have
been begging for this get it, they _will_ start using it all over
the place.
I would have thought that we'd define this such that the compiler
introduced a variable restricted to the scope of the statement
for each rvalue passed as an auto ref parameter rather than
introducing function overloads. No, that's not quite as nice a
lowering, but it would avoid a lot of extraneous function
definitions.
- Jonathan M Davis