You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/usr/local/share/lua/5.1/argcheck/init.lua:105: could not generate argument checker: [string "argcheck"]:35093: control structure too long near 'end'
stack traceback:
[C]: in function 'error'
/usr/local/share/lua/5.1/argcheck/init.lua:105: in function 'argcheck'
[string "initcheck = argcheck{..."]:1: in main chunk
[C]: in function 'xpcall'
/usr/local/share/lua/5.1/trepl/init.lua:567: in function </usr/local/share/lua/5.1/trepl/init.lua:468>
You have many default variables.
The case of ordered arguments:
initcheck("a", "b", "c"...)
generates only 10 cases, that is ok.
But in the named argument case, that generates a lot of things, because you can specify any argument to be there or not (and argcheck checks all possible cases)
initcheck{x3="a", x5="b", x10="e") -- note this is not possible with ordered arguments.
This case generate 15K lines of code (see with argcheck{debug=true, ...}). Unfortunately, luajit (which has much more limitations than lua) does not support it (lua is ok though).
If you do not need named arguments, then deactivate it with argcheck{nonamed=true, ...}, and you will be fine. If you really need named arguments for that case... hmmm... i have to think about workarounds which would work with luajit. I could also add an option such that the behavior is the same than with ordered arguments (like initcheck{x1="a", x2="b} is ok, but initcheck{x2="a", x3="b"} is not).
Hi @andresy - any further thoughts on how to solve this? I'd like to overcome this in my application without using hacks like combining arguments into tables, manually defaulting values, or not using named arguments. I'd be happy to contribute some code to resolve this.
@bamos I wrote a simple workaround function sometime ago specifically for this case. It would sure be much better to solve this problem in argcheck though.
Activity
andresy commentedon Jan 23, 2015
You have many default variables.
The case of ordered arguments:
initcheck("a", "b", "c"...)
generates only 10 cases, that is ok.
But in the named argument case, that generates a lot of things, because you can specify any argument to be there or not (and argcheck checks all possible cases)
initcheck{x3="a", x5="b", x10="e") -- note this is not possible with ordered arguments.
This case generate 15K lines of code (see with argcheck{debug=true, ...}). Unfortunately, luajit (which has much more limitations than lua) does not support it (lua is ok though).
If you do not need named arguments, then deactivate it with argcheck{nonamed=true, ...}, and you will be fine. If you really need named arguments for that case... hmmm... i have to think about workarounds which would work with luajit. I could also add an option such that the behavior is the same than with ordered arguments (like initcheck{x1="a", x2="b} is ok, but initcheck{x2="a", x3="b"} is not).
bamos commentedon Mar 28, 2016
Hi @andresy - any further thoughts on how to solve this? I'd like to overcome this in my application without using hacks like combining arguments into tables, manually defaulting values, or not using named arguments. I'd be happy to contribute some code to resolve this.
-Brandon.
fmassa commentedon Mar 28, 2016
@bamos I wrote a simple workaround function sometime ago specifically for this case. It would sure be much better to solve this problem in
argcheckthough.