-- output() outputs to stderr local dump = require 'dump' local function output(...) local need_newline = false for i, item in ipairs({...}) do -- XXX space logic could be cleverer, e.g. no space after newline local maybe_space = i > 1 and ' ' or '' local text = ({table=1, userdata=1})[type(item)] and dump(item) or tostring(item) io.stderr:write(maybe_space, text) need_newline = text:sub(-1) ~= '\n' end if need_newline then io.stderr:write('\n') end end return output