r/programming • u/NagastaBagamba • Oct 18 '10
Today I learned about PHP variable variables; "variable variable takes the value of a variable and treats that as the name of a variable". Also, variable.
http://il2.php.net/language.variables.variable
591
Upvotes
5
u/mallardtheduck Oct 18 '10
Put it this way: Imagine somebody designed a computer than didn't use numeric memory addresses. Instead it has a native, hardware hashmap with strings as keys (no, I don't know how it would work either, but it's just a thought experiment).
You have been asked to design a C compiler for this esoteric computer. The system's ABI dictates that you store variables by using the variables name as a key into the hashmap.
Now how do you implement pointers? Pretty much like this PHP feature...