Pass by reference

Xinok xnknet at gmail.com
Fri Jun 8 10:29:23 PDT 2007


Main reason I can think of is function overloading. This is an 
acceptable overload:

void foo(A a)
void foo(A* a)

And if you allow 'a' to automatically convert to '&a':
foo(a); // Ambiguous error

Regan Heath wrote:
> Hmm.. idea;  why not allow foo(a) and automatically convert to foo(&a) internally if 'a' is not a pointer.  I mean, the compiler knows what 'a' is, it knows what 'foo' wants, why can't we have the syntax automatically, much like we do for dereferencing.
> 
> Regan



More information about the Digitalmars-d mailing list