print out the "address" of a variable, not table

Out of curiosity, is there a way to print the memory address of a variable in Lua? If it’s a table or function, using print command will out its address, but what if it’s just a variable?

As best I can tell through Google-fu, the answer is no, you can’t find the starting address of a variable.

You can’t print out the address of variables.   Even in the case where the variable is a table, you’re not printing out the address of the variable, but the address of the memory allocated for the table. 

Hi Rob, What I meant by address is actual the one that you mentioned, the address of the memory allocated. I remembered long ago when I learned C, there was a way to print out the address of the memory allocated to a variable using a & sign in front of variable:  &var. I did search on google and the lua manual, and didn’t find any word on it exactly. Now that I know there is no such equivalent thing in lua.

Thanks all :slight_smile:

As best I can tell through Google-fu, the answer is no, you can’t find the starting address of a variable.

You can’t print out the address of variables.   Even in the case where the variable is a table, you’re not printing out the address of the variable, but the address of the memory allocated for the table. 

Hi Rob, What I meant by address is actual the one that you mentioned, the address of the memory allocated. I remembered long ago when I learned C, there was a way to print out the address of the memory allocated to a variable using a & sign in front of variable:  &var. I did search on google and the lua manual, and didn’t find any word on it exactly. Now that I know there is no such equivalent thing in lua.

Thanks all :slight_smile: