lua-users home
lua-l archive

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


Thanks everyone who has helped me today.  I have one more question. Given:

jgl = {}
jgl_meta = { __index = function(t, k)
						print("__index: " .. k)
                       return function(t, ...)
                           jgl.set_command_buffer(k, ...)
                       end
                    end
        		  }


setmetatable(jgl, jgl_meta)

command_buffer = {}

function jgl.set_command_buffer(...)
	print("command: " table.concat({...}, ", "))
	command_buffer[#command_buffer+1] = {...}
end

A call like:
jgl.line(2., 3., 4., 5.);

will print "command: line, 3, 4, 5"

whereas:
jgl:line(2., 3., 4., 5.);

will print "command: line, 2, 3, 4, 5"

I realize that jgl:line(2., 3., 4., 5.); is like calling jgl.line(jgl,
2., 3., 4., 5.); but why would the first argument to my function be
dropped in the former case and not in the latter?

thanks,
wes