When a variable is passed into a function, is its name kept somewhere for the function to acceess

DlangLearner via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Nov 10 06:14:32 PST 2015


Here is what I want to know: when a function is called, does this 
function can recovery the information about which variables pass 
their values into this function's arguments. I use the following 
example to show what I want to know.

void main(){
	int a = 1;
	writeln(fun(a.stringof, a));
}

//to return "a is assigned to 1"
string fun(string name, int x)
	return name~" is assigned to "~x;
}

For this example my question turns to become: can the name for 
fun be derived instead of passing to it?

string fun(int x)
	//is there any way we can know that this value x is passed from 
the variable a in the main function?
	string name = the name of the variable which passes its value to 
x	
	return name~" is assigned to "~x;
}

Please enlighten me if this can be done, thanks.


More information about the Digitalmars-d-learn mailing list