lua-users home
lua-l archive

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


On 13/08/2014, at 10:34 am, astient@laposte.net wrote:

> Sorry, i forgot to ask you why in this case Lua accept this way to define identifiers with an accent:
> 
> table={}
> table["caché"]="test"
> 
> isn't this way equivalent to: table.caché="test" ? However the first one is accepted (i can do a print of table["caché"]) but the second gives an error as you explain.

If it helps understand, it’s legal to set 'table[“this has spaces”]', but 'table.this has spaces’ obviously won’t work.  Table keys can be pretty much anything (strings, numbers, tables, functions), but you when you’re using the ‘.’ notation you can only use keys that parse as identifiers.