lua-users home
lua-l archive

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


Hi all,

I know that in this list there are a lot of clever guys so I guess it is the good place to ask *very* difficult questions about Lua :-)

For my project, GSL shell, I would like to slightly modify the Lua parser to add some syntactic sugar. For example I would like to write:

|x| sin(x)/x

or

|x, y| sin(x) * cos(y)

as a function literal instead of

function(x) return sin(x)/x end
or
function(x,y) return sin(x) * cos(y) end

Incidentally, this syntax is supported by metalua.

Otherwise I would like to index object with more comma-separated values because for a matrix is natural to write something like m[i, j] to refer to an element of the matrix. Right now I'm doing m:get(i, j) but I would like to simplify the notation.

It seems that metalua can offer all these things but I'm wondering if it is really the good choice. The other alternative could be to hack the Lua code to modify the parser. I'm ready to fiddle my hands in the Lua code but the source code is quite complicated and I didn't find any tutorial on 'hacking Lua' so it is very difficult to start.

Thank you in advance for any help.

Francesco