lua-users home
lua-l archive

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


Thanks for the pointer and suggestions, David.

So recapping Roberto's answer, this initialization syntax doesn't exist
because:

   * We don't know how the syntax would work.
   * The syntax would be difficult to implement.

Re. how the syntax would work, any semantics are fine as long as they're
consistent.  IE pick some behavior for the new type of initializer list,
document it, and implement it.  No old code will be broken, so arbitrarily
pick a behavior.  There is no wrong answer.

Re. the implementation difficulties.  That's more understandable... Lua
tends to stick to the simplest thing that works, and avoid conveniences
 like "for" loops ).  Perhaps, though, the artibrary semantics of the syntax
could be chosen to simplify implementation.  Since there's no wrong answer,
pick whatever behavior is easiest to implement.

Granted the syntax isn't indispensable, I think it would make a nice
addition on the grounds that it makes the language more flexible and easy to
use, which are worthy goals for Lua.

ashley


> -----Original Message-----
> From: lua-l@tecgraf.puc-rio.br [mailto:lua-l@tecgraf.puc-rio.br]On
> Behalf Of David Jeske
> Sent: Sunday, August 29, 1999 10:29 AM
> To: Multiple recipients of list
> Subject: Re: Table constructors
>
>
> On Sun, Aug 29, 1999 at 05:49:40AM -0300, Ashley Fryer wrote:
> > I'm curious, is there some reason why the two types of table field
> > initialization lists can't be merged?
>
> I think this is an RTFM..
>
> > This would become legal syntax:
> >
> >   t = { 42, name = "bob", 45, color = "blue" }
>
> Just do:
>
>     t = { 42, 45 ; name = "bob", color = "blue" }
>
> For some justification of why the numbered and keyed parts have to be
> separated, see this message from the archive:
>
> http://www.egroups.com/group/lua-l/296.html?
>
>
>
> FYI: you can also do:
>
>     t = { [1] = 42, ["name"] = "bob", [2] = 45, ["color"] = "blue" }
>
> --
> David Jeske (N9LCA) + http://www.chat.net/~jeske/ + jeske@chat.net
>