lua-users home
lua-l archive

Thoughts on optional commas

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


Occasionally I forget commas when I create large nested tables in Lua. It
reminds me of when I was learning c and always forgetting to place semicolons at
the end of a line. I'm so happy that semicolons are optional in Lua. I wish
commas were too.
Could this work?
Example:
local node= {
 {template="window"
 {template="rect" x=10 y=100 alpha=1
 
 s1 = {color="red"}
 s2 = {color="blue" x="=x+1"}
 s3 = {color="blue" x=10}
 }
 {template="textbox" }
 }
}
Instead of traditionally:
local node= {
 {template="window",
 {template="rect", x=10, y=100, alpha=1,
 
 s1 = {color="red",},
 s2 = {color="blue", x="=x+1",},
 s3 = {color="blue", x=10,},
 
 },
 {template="textbox", },
 },
}
I always end up using trailing commas in my tables and it feels wasteful. 
Any thoughts?

AltStyle によって変換されたページ (->オリジナル) /