lua-users home
lua-l archive

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


That's a good point. But in my case, ``fn_name'' has to be the first parameter.
So ``_G'' seems the way to go.

Wei

On Fri, Jan 4, 2013 at 9:28 PM, Drake Wilson <drake@dasyatidae.net> wrote:
[snip]
 
But it might be easier, more composable, and more obvious that a
global is being defined if fn_matrix were to return the new function
instead.  Then you'd do:

  new_fun = fn_matrix(arg_foo)
  new_fun(...)

Note that these are already equivalent:

  function f(...) ... end
  f = function(...) ... end

(Though if you have another reason to use the _name_ of the desired
function in its construction, then you wind up having to pass the name
in as well, thus specifying it twice, which is not so good---in that
case, the tradeoff may be different.)

   ---> Drake Wilson