lua-users home
lua-l archive

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


Hello

We like Lua for its facility in self-declarative data description. But I
am Spanish and I want to prepare a program that need table field names
with accented characters. Yes, I know the problem of portability, but
we could prepare a version for every language I want.

I know that the format table["blá"] is always possible, but it is
cumbersome because other (non programmers) people will be the users of
my program. Concretely the user will introduce in a file (it is only a
simplified example):

-----------method_1--------------
Entrada1 {
   título = "Algún libro",         -- simple
   año = 1992
}
--------------------------------

instead of:

-----------method_2--------------
Entrada2 {
   ["título"] = "Algún libro",    -- cumbersome
   ["año"] = 1992
}
--------------------------------

The program, that will process the previous chunk with dofile(), could be:

-----------method_2--------------
function Entrada1 (o)
   print(o["título"])
   print(o["año"])
end
--------------------------------

but it will be better to use:

-----------method_1--------------
function Entrada1 (o)
   print(o.título)
   print(o.año)
end
--------------------------------

(This part of the problem is not very difficult, as I could use method_2
inside the code.)

I have a Debian Linux (frequently updated).
In this machine method_2 obviously works.
But method_1 works ONLY if I type the program INSIDE the Lua intrepreter (I tried versions 5.0 and 5.1)!

For example if I do

  lua method_1

the intrepreter protests:

  lua: method_1:3: ')' expected near 'í'  --in the í of título in Entrada1

----------------------------------------
Note.-

I have the locale:
LANG=es_ES@euro
LC_CTYPE="es_ES@euro"
LC_NUMERIC="es_ES@euro"
LC_TIME="es_ES@euro"
LC_COLLATE="es_ES@euro"
LC_MONETARY="es_ES@euro"
LC_MESSAGES="es_ES@euro"
LC_PAPER="es_ES@euro"
LC_NAME="es_ES@euro"
LC_ADDRESS="es_ES@euro"
LC_TELEPHONE="es_ES@euro"
LC_MEASUREMENT="es_ES@euro"
LC_IDENTIFICATION="es_ES@euro"
LC_ALL=
----------------------------------------

I think this is also a problem with with luacheia and lua in Windows XP.

Why the interactive lua works differently than the non-interactive one
(in this subject)?

What is the solution? I read many posts in lua-l archive but I have
found none.

Thank you in advance.

Manel