lua-users home
lua-l archive

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


Hi,

On Thu, Aug 7, 2008 at 12:48 PM, Hartmut Henkel <hartmut_henkel@gmx.de> wrote:
> Hi,
>
> it is so practical to store data in a transparent way within data files
> by Lua tables like
>
> keytable{
> words = 625000,
> wordsize = 32,
> randmax = 4294967296,
> key = {
> 3608578767,
> 1693861772,
> [ ... 624997 values omitted ... ]
> 3780027093,
> }}
>
> and reading them in by dofile() (cf. PiL, 12.1 Data Files), but the
> above one gives a "lua: constant table overflow" error. 625000 values
> isn't that much nowadays. It would be very nice if Lua could be made to
> "think big" in these cases.
>
> Is there some trick to circumvent this limitation (while keeping such a
> structure)?
>
> Regards, Hartmut

The limit is on a per function basis. If you do something like:

t = {}
(function()
  t["blah"] = 5324,
  ...
end)() -- first ~600000 entries

(function()
  t[5345] = 532344,
  ...
end)() -- second ~600000 entries

Then you can fill up a table to pretty much any size.

Cheers,

-- 
-Patrick Donnelly

"One of the lessons of history is that nothing is often a good thing
to do and always a clever thing to say."

-Will Durant