lua-users home
lua-l archive

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


Blargh... This kind of wording sounds... kind a misleading. Just some sugar for expressing a function COMPOSITION as a concatenation.
 
> variable to hold the parent function seems very ugly to me.

  You could get fancy (or scary, depending upon your viewpoint):

        _function_mt =
        {
          __concat = function(f1,f2)
            return function(...)
              return f2(f1(...))
            end
          end
        }

        debug.setmetatable(debug.getmetatable(print),_function_mt)

        dosomething = module1.dosomething .. module2.dosomething

        print = function(...)
          log('debug',"calling print")
          return ...
        end
        .. print ..
        function(...)
          log('debug',"done calling print")
          return ...
        end

  -spc (Betcha didn't know you could concat functions?)