lua-users home
lua-l archive

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

On 1-Feb-06, at 3:45 PM, Doug Rogers wrote:

Chris Marrin wrote:

Wow, that seems like a lot of work. Has anyone done a library to make
any of this simpler?

Well, the meat of it is only a handful of lines of Lua. If you can live
without the flexibility of establishing your own types (a different
thread recently discussed), then it could be as simple as:

function types(args)
   local tt = {}
   table.foreachi(args, function(_,v)
                           table.insert(tt, ',' .. type(v))
   return string.sub(table.concat(tt), 2)

or even (5.1):

function types(args)
  local tt = {}
  for i = 1, #args do
    tt[i] = type(args[i])
  return table.concat(tt, ",")

(assuming that no arg is nil, of course :)