lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Thursday 28 October 2004 17:55, Rici Lake wrote:
[...]
> Possibly. Consider the following:
>
> local a = {}
> for i = 1, 1000000 do a[i] = "X" .. i end
> local b = somefunction(a, x)
> -- no more references to a
>
> In that case, a will live until the end of the scope, which
> might be some time distant.

In fact, the compiler *could* notice the fact that a isn't used any more and 
so reuse the same stack slot for a different variable. I don't know whether 
it does or not; it's a fairly obvious compiler optimisation.

-- 
+- David Given --McQ-+ 
|  dg@cowlark.com    | Quidquid latine dictum sit, altum viditur.
| (dg@tao-group.com) | 
+- www.cowlark.com --+