lua-users home
lua-l archive

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


Hello, recently I worked again with lualatex* and again one of my biggest gripes was Lua not allow trailing commas on function calls. 

tex.write(
   '\\begintable{}', value, 'bla',
   '\\endtable{}',
);

results in: unexpected symbol near ')'

I know I made this case before (including patch) but I want to give it another shot.

Note:
* these argument lists can get pretty long, and added new stuff or removed stuff quickly while coding
* { } objects allow trailing commas, because "created automatically". I don't see why sometimes you wouldn't create code that also includes calls with arbitrary arguments automatically (I certainly have)
* I know you could work around this (and thats what I'm doing now) by having this functions take one table as argument only. Like mycall{ 'foo', 'bar', }. However despite jumping to some hoops in the callee. It's not really understandable for others editing my code, why some calls have () and some have {}.
* there just is no implicit "nil", neither in the call nor in the object. 
* It's just one line of code that needs changing for this syntax to valid. It would make live easier for some. I don't see any harm in it (except the argument back then, that some people brought up alternative ideas for "implicit nils" that didn't happen anyway, and would have been in conflict)

Please give it another thought. Yes, there are use cases out there where this would be a small quality of live improvement.

- Axel

* In this recent case I wrote a small Lua wrapper around tikz, since I prefer to have a "real" programming language when doing geometric calculations, instead of jumping through the \pgfmathresult hoops. And yes I want it to be Lua, since that's integrated in lualatex alrady. Anyway, my wrapper takes for example "paths" and "drawing options" yes thats a lot of arguments and yes the non allowed trailing commas is either a constant nuisance, or unnecessary bloat by taking single argument tables instead with for others confusing () and {} differentiation.