|
Sometimes, you cannot avoid it. For example when generating a 1-1 binding to a library which uses methods named as Lua keywords. An example of this is the Qt library - 19 of it's classes have a method named 'end' [1], which you cannot call using Lua's syntax sugar. You have to call it as follows: painter['end'](painter) Does someone propose an elegant way to handle this? :)painter._end = painter['end']
You can use uppercase: for k, v in pairs(painter) do if type(k) == "string" and type(v) == "function" then local K = k:gsub("^(.)", string.upper) painter[K] = v end end assert(painter['end'] == painter.End) Or, if you prefer, do it only for the keywords... Regards, Tomás