How to get an instance name and use it as a variable?

How do I get the name of an instance and use it as a variable?

Something like:

my_name = getInstancename(this);