lua-users home
lua-l archive

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


On Sat, Jan 5, 2013 at 11:55 AM, Grizzly Bear <6grizzlybear@gmail.com> wrote:
I'd like to have a meta function, sth. like

        function fn_matrix(fn_name, arg_foo)
                string2var(fn_name) = function(arg_foo) print(fn_name, arg_foo) end
        end

Every time fn_matrix is called, it creates a function of the name fn_name that takes
arg_foo as the first parameter and prints out the function's own name and
arg_foo.

Thanks.
Wei


Wouldn't you be able to replace string2var(fn_name) with _G[fn_name] to create a global function of the specified name?