lua-users home
lua-l archive

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


On Mon, Dec 22, 1997 at 12:09:29PM -0200, Roberto Ierusalimschy wrote:
> > Why does the syntax enforce numbered items before string items though? It
> > seems with the syntax you present above, there would be no confusion, even
> > when alternating numbered and string entries,
> 
> We think it would be confusing to allow a free mix of both "record" and
> "list" styles in a table construction; for instance:
> 
> a = {'a', 'b', [4]='c', 'd'}
> 
> The element 'd' should be in index 3, 4 or 5? Moreover, this free mix would
> complicate the code generation.

I understand completely with the syntax above.

> However, we are considering in Lua 3.1 to
> allow the "record" part to come before the "list" part, as in:
> 
> a = {style = "picture"; 'a', 'b', 'c'}

I think this would be a good solution. The "general" form of this could be
that you can only have one "list" part, and it must be separated from any
"record" parts by semicolons. For example:

a = { <optional list part> ; <optional record part> ; <optional list part> };

Can anyone else see any need to have multiple record parts? 

-- 
David Jeske (N9LCA) + http://www.chat.net/~jeske/ + jeske@chat.net