lua-users home
lua-l archive

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


> > Given:
> > 
> > 	t = { 1 , 2 , 3 , ... }
> > 
> >   What's the difference between
> > 
> > 	t = {}
> > 
> > and
> > 
> > 	table.clear(t)
> > 
> >   -spc (Curious about this ... )
> 
> There might be other references to the table.
> 
> t = { ... }
> a = t
> 
> table.clear(t) --> a and t are still referencing the same table, which
> is now cleared.
> 
> t = {} --> t got a new empty table, a has still the old table with all
> the values.

Moreover, table.clear should be able to release the memory used by the table
immediately, independent of the GC.

-- Roberto