lua-users home
lua-l archive

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


Andrea:

On Mon, May 25, 2020 at 2:33 AM Andrea <andrea.l.vitali@gmail.com> wrote:
> Overall the table constructor is not bad.
> One source of mistake for me is that when I see a name=value in the table constructor, the name looks like a variable to me, not a literal string, because any hint is missing: no quotes, no dot

On many scripting languages, and I suspect lua too, this in intentional.

Let me explain how it works for me. When I use tables  as
struct/objects they read naturally:

local point = { x=1, y=2, z=3}

An when I use them as named parameters they do too:

return outgoing_trunk:make_call{caller=src_number, called=dst_number,
time_limit=120000 }

And it couples naturally with the shortcut indexing access point.x

I do not normally have non-keywords elements in constant tables.

Normally in all my real world access to any-string, or number keys I
do indexing and I have the data in some var.

The exception being some test structs:

local test_routes = { ["34912345678"] = spain_trunk }

But in production I normally would have read that from some data
source an do test_routes[number]=route.

FOS