Address of a variable: Difference between revisions

→‎{{header|Lua}}: added Lua solution
(removed {{omit from|Lua}} - will provide a partial solution with description of limitations)
(→‎{{header|Lua}}: added Lua solution)
Line 1,124:
-> {+ 1 2} // as displayed after post-processing
</lang>
 
=={{header|Lua}}==
Pure/native Lua does not support true pointer operations. Memory management is automatic, and garbage-collected, so at best you can hold a temporary reference to the allocated memory. However the "virtual address" of complex types is discoverable (and is in fact how the internals deal with assignment, equality testing, etc), and userdata types typically reveal an actual physical address.
<lang lua>t = {}
print(t)
f = function() end
print(f)
c = coroutine.create(function() end)
print(c)
u = io.open("/dev/null","w")
print(u)
print(_G, _ENV) -- global/local environments (are same here)
print(string.format("%p %p %p", print, string, string.format)) -- themselves formatted as pointers</lang>
{{out}}
<pre>table: 00000000001d93b0
function: 00000000001dcb30
thread: 00000000001de088
file (00007ffe2612fa90)
table: 00000000001d1e80 table: 00000000001d1e80
0000000065b9cd60 00000000001d90b0 0000000065ba34f0</pre>
 
=={{header|Maple}}==
Anonymous user