[dmd-beta] D 2.059 beta 4

Michel Fortin michel.fortin at michelf.com
Mon Apr 9 21:39:26 PDT 2012


Le 2012-04-10 à 0:06, Jonathan M Davis a écrit :

> Having to duplicate pretty much every single function which takes a const ref 
> - opEquals and opCmp being very prominent among them - is a definite problem. 
> That's the problem that auto ref was intended to solve, and as long as it only 
> works with templated functions, it really doesn't solve the problem.

I think the implementation of auto-ref you want is one where the argument is always passed by ref but it the function would also accept lvalues. I think "auto ref" is a misnomer for that.

Actually, I think the true problem you are trying to solve using auto-ref is one of efficiency: you don't want all structs to be passed by copy because often that'd be inefficient. Disregarding efficiency, all cases where you want to use auto-ref you could pass the struct by copy instead. Am I right?

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/





More information about the dmd-beta mailing list