Why can't we make reference variables?

Tommi tommitissari at hotmail.com
Tue Aug 28 18:44:38 PDT 2012


On Wednesday, 29 August 2012 at 01:28:49 UTC, Jonathan M Davis 
wrote:
> Not going to happen. Unfortunately though, I don't remember all 
> of Walter's reasons for it, so I can't really say why (partly
> due to complications it causes in the language, I think, but I
> don't know).

I'd really like to hear about those complications (unless they're 
too complicated for me to understand), because for someone like 
me, not knowing the implementation details of the language, it 
looks like the language already *has* implemented reference 
variables. We just can't create them, apart from these few 
distinct ways:

foreach (ref actualRefVariable, array)
{
     ++actualRefVariable; // <-- that's a reference variable 
alright
}

void fun(ref int actualRefVariable)
{
     ++actualRefVariable; // <-- that's a reference variable 
alright
}


More information about the Digitalmars-d mailing list