Variadic function parameters passed by move

Nordlöw via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Dec 21 15:18:29 PST 2016


On Wednesday, 21 December 2016 at 23:11:02 UTC, Nordlöw wrote:
>> Given that ref isn't involved, assuming that nothing else 
>> after the call to g references ranges, the compiler should 
>> move the values in ranges when it calls g

Yes, DMD should automatically convert the last reference of a 
value expression to an r-value. This, most likely, involves 
calling doCopyOrMove() on the correct AST node somewhere in 
dmd/src/expression.d.

But I haven't figure out how to do this. I have and idea outlined 
here: 
https://github.com/nordlow/dmd/commit/d3053e7801e340541bba32172718c2bb3de966c0

But I need feedback from the kernel developers on how go forward 
with this. Specifically the visitor that finds the last reference 
of a symbol that can be passed by move (non-reference) parameter 
in current function (scope).

Do you have any clue on how to most easily find detect whether a 
SymbolExpression is the last reference to that symbol in the 
scope of the symbol definition, Jonathan?

If this gets fixed we will have yet another way of programming 
with ranges in D that will require neither RC nor GC!


More information about the Digitalmars-d-learn mailing list