lua-users home
lua-l archive

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


Hi Mike,
 >> Redefining getn() would be more problematic, as it would need to
 >> detect whether or not it was working on a "special" table.

   This is one of my favorite aspects of Lua.  :-)  I frequently use it to
redefine tostring() so I can easily print debug dumps of custom structures.
 There's lots of uses.  Your getn() might look something like:

  function getn(t)
    if (tag(t) == MySpecialTag)) then
      return MySpecialGetN(t)
    else
      return %getn(t)
    end
  end

   Cheers,
   Dave