Destructors, const structs, and opEquals

Michel Fortin michel.fortin at michelf.com
Mon Dec 13 19:20:43 PST 2010


On 2010-12-13 17:54:57 -0500, Don <nospam at nospam.com> said:

> BTW the really big problem I have with 'auto ref' is that it isn't 
> 'auto', and it isn't 'ref'. I wouldn't have the same objection to 
> something like 'autoref'.

I don't like "auto ref" as a syntax either, but I also dislike the 
general direction this solution is leading us to (irrespective of the 
syntax). One shouldn't have to specify for every function whether the 
argument should be passed by ref or by copy under the hood. That's just 
repeating C++ mistake where for certain type you almost always have to 
use the easy the idiom "const T &" for function parameters. Efficiency 
should be the default way to pass function parameters around.

I made a proposal earlier that instead of having "auto ref" for this we 
could have a way to define a struct as being automatically passed by 
ref in function calls. This way you don't have to remember to pass them 
by "auto ref" to be efficient, it's done automatically. I said earlier 
that the default way to pass parameters should be efficient, and this 
is what it allows.

Earlier proposal:
<http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D&artnum=123991>


-- 


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



More information about the Digitalmars-d mailing list