Arena storage pool: Difference between revisions

Content added Content deleted
(→‎{{header|Lua}}: added Lua)
Line 685: Line 685:
1 + 2 = 3
1 + 2 = 3
</pre>
</pre>
=={{header|Lua}}==
Lua is a higher-level language with automatic allocation and garbage collection, and in most cases the programmer need not worry about the internal details - though some control over the strategy and scheduling of the garbage collector is exposed. ''(the reader is directed to the Lua Reference Manual if further internal specifics are desired, because it would be impractical to reproduce that material here, particularly since the details may vary among releases)''

If the goal is to simply create a collection of 'objects' that can be deleted en masse as a group, here is one possible approach that might suffice..
<lang lua>pool = {} -- create an "arena" for the variables a,b,c,d
pool.a = 1 -- individually allocated..
pool.b = "hello"
pool.c = true
pool.d = { 1,2,3 }
pool = nil -- release reference allowing garbage collection of entire structure</lang>


=={{header|Mathematica}}==
=={{header|Mathematica}}==