[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Minor problem with tables (I think)
- From: Paul Bleisch <bleisch@...>
- Date: Thu, 11 Dec 1997 20:09:59 -0800
lua-l
I was messing around trying to use lua as a model definition
system and came across a small problem I think. For some reason:
Foo = {
Name="Foo",
{0,1,2,3,4}, -- <-- here see note below
{1,2,3,4},
{2,3,4},
{3,4}
};
The problem is that lua cannot seem to handle unnamed and named
fields in a table constructor. i.e. The above example fails with
a syntax error on line 3 (marked above) and the last token is '{'.
If I remove the Name="Foo", line everything is hoopy. Looking
at the definition in the documentation, I can see why this is an
error, but I don't understand why it can't be handled.
If I understand things correctly, I should do:
Foo = {
[Name]="Foo",
{0,1,2,3,4},
{1,2,3,4},
{2,3,4},
{3,4}
};
But this doesn't seem to work either. My goal is to allow
people to describe relatively complex heirarchies of objects
with the pretty simple syntax of table constructors. I don't
want to have to do something like:
Foo = {
Name="Foo",
Foo0={0,1,2,3,4},
Foo1={1,2,3,4},
Foo2={2,3,4},
Foo3={3,4}
};
Any ideas?
Paul
--
Paul Bleisch
bleisch@chromatic.com