lua-users home
lua-l archive

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


Philippe,

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 

Instead of T = { x=1, y=2 } 

I would strongly prefer T = { .x=1, .y=2 }

the Dot is the hint that this is equivalent to T = { [“x”]=1, [“y”]=2 }

if there is no dot, each item in the constructor could be an _expression_ (value) or exp=exp (key=value), there would be no square brackets

T = { a=b } would be same as T = { [a]=b } Where a is a variable holding the key and b is another variable holding the value 

But if you look at it, the absence of square brackets may make more difficult to immediately catch the key when reading the code 

I mean square brackets make keys very different with respect to values and that is good, is not it?

I have not studied the current parser, maybe there is a good reason to have mandatory square brackets to indicate a key _expression_?

Maybe this make the parser simpler and faster?

Or square brackets could be eliminated as suggested above? (When there is no dot expkey=expval or just expval, with the dot .key=val)

   Andrea 
--
Andrea Vitali