Discussion:
"constant table overflow"
Miles Bader
2010-11-30 04:58:44 UTC
Permalink
Are there good workarounds for this?

I mean, if I have a file like:

local function T(x,y,z)
foooo (x,y,z)
end

T(1,2,3)
T(11,12,13)
T(21,22,23)
...
T(999981,999982,999983)
T(999991,999992,999993)

Lua can't load it, because there are too many constants...

Similarly, it can't load a file like

list = {
{1, 2, 3},
{11, 12, 13},
{21, 22, 23},
...
{999991, 999992, 999993}
}

process (list)

for the same reason.

Isn't this sort of thing supposed to be Lua's forte...?

[I guess I can do it by putting the contents in an _enormous_ string,
which I then parse, but geez... One really shouldn't have to do that
kind of thing!]

Thanks,

-Miles
--
Patience, n. A minor form of despair, disguised as a virtue.
Miles Bader
2010-11-30 05:02:16 UTC
Permalink
Post by Miles Bader
Are there good workarounds for this?
...

BTW, I'm thinking of a context where there's limited control over the
generation of the input file -- i.e., a template-system where one can
specify a file header and a pattern to be repeated for each data line,
but doing things like splitting up the file into smaller chunks isn't
so easy.

Thanks,

-Miles
--
Everywhere is walking distance if you have the time. -- Steven Wright
Miles Bader
2010-11-30 05:24:39 UTC
Permalink
hmm, I notice that the max number of constants has been significantly
increased in lua 5.2 alpha... so I guess that's one reason to switch to
5.2! :)

but luajit support is a problem... :(

-miles
--
Year, n. A period of three hundred and sixty-five disappointments.
Alexander Gladysh
2010-11-30 05:12:35 UTC
Permalink
Post by Miles Bader
Are there good workarounds for this?
This was discussed a number of times on the list:

http://www.google.ru/search?q=site:lua-users.org+%22constant+table+overflow%22

Basically, the limit is per chunk. So, multiply your chunks (functions).

Alexander.
steve donovan
2010-11-30 05:48:51 UTC
Permalink
Post by Alexander Gladysh
Basically, the limit is per chunk. So, multiply your chunks (functions).
So, let me see if I understand. If the file looked like this:

(function()
f(1),
f(2),
..
f(MAX_VARS)
)()
(function()
f(MAX_VARS+1)
...
f(MAX_VARS+MAX_VARS)
)()

etc, it would work?

One could also make the closures tables and loop over them later.

A little more work for the template, but that's also what Lua is good for ;)

steve d.
Kristofer Karlsson
2010-11-30 07:29:08 UTC
Permalink
I for one think it would be nice if the compiler could do this by itself
when it notices that the constant pool is full.
Post by steve donovan
Post by Alexander Gladysh
Basically, the limit is per chunk. So, multiply your chunks (functions).
(function()
f(1),
f(2),
..
f(MAX_VARS)
)()
(function()
f(MAX_VARS+1)
...
f(MAX_VARS+MAX_VARS)
)()
etc, it would work?
One could also make the closures tables and loop over them later.
A little more work for the template, but that's also what Lua is good for ;)
steve d.
Javier Guerra Giraldez
2010-11-30 13:10:43 UTC
Permalink
On Tue, Nov 30, 2010 at 2:29 AM, Kristofer Karlsson
Post by Kristofer Karlsson
I for one think it would be nice if the compiler could do this by itself
when it notices that the constant pool is full.
that would change the semantics
--
Javier
Loading...