lua-users home
lua-l archive

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


My two cents ;-)
We have autodiff software which generates long automatic programs in Lua. In general it is hard to reach the limit, but eventually we deal with the same problem in a few particular cases. However, and as it has been commented above, avoiding this problem is easy using a table to store your variables. It can be done in a clean and automatic way by modifying the global environment at the top of the generated code:

  _ENV=setmetatable({},{__index=_G})

and obviously removing "local" keyword when declaring variables. So, it is not a big deal.


On 28 April 2015 at 07:01, Dirk Laurie <dirk.laurie@gmail.com> wrote:
2015-04-27 23:56 GMT+02:00 Peter Hickman <peterhickman386@googlemail.com>:
> On 27 April 2015 at 22:05, Ignacio Burgueño <iburgueno@gmail.com> wrote:
>>
>> Well, I see your point. But here we are presuming "no investigation" on
>> the OP part, no?
>>
> The Lua community is much more technically adept than average bunch of
> programmers and as such I expect a little more self investigation before
> asking a question. Simple ones like "Why does the number of local variables
> I declare affect which part of the table assignment errors?" or "Why does
> Lua not assign a local variable only once?" raise themselves after only a
> brief time spent playing with luac -l and the original program.
>
> There are other variants of the original program, such as one where there
> are thousands of 0s, before the nested table. The fact that it is 50
> elements before the nested table is a red herring and one that would be
> quickly found. Likewise why is it the inline nesting of a table that
> triggers the error and not when it is added as a separate step "a[#a] =
> {1,1,....1}"?
>
>> Why such short code is considered to be "too complex"?
>
> Does not seem to touch on any of the issues that the code raises. Which I
> why I believe that the poster has conducted no investigation.

The problem was not the original post, which simply presented
a short, simple program generating an error message that
most of us have never seen, and which therefore was interesting
in the same way that an unusual wildlife photograph is interesting.
This particular poster has a record of unearthing Lua curiosities
leading to deep and fundamental discussions such as the
recent thread on comparisons between floats and very large
integers, which seems likely to have some impact on Lua 5.3.1,
and my first reaction was overwhelmingly positive.

The problem was his second post, which raised the hair on
everybody's back, containing as it did:

(a) An invidious comparison with LuaJIT.
(b) An admission that the example is artificial.
(c) The phrase "some strange complexity limitations".
(d) A blunt statement of what the manual "must" do
rather than a politely phrased suggestion of what it
might do.
(e) A sneering rhetorical question to the effect that
Lua is "suitable only for short human-written code".

Let's all just cool it.