lua-users home
lua-l archive

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


On 28 June 2013 10:03, Michal Kolodziejczyk <miko@wp.pl> wrote:
type=function(o)
  if getmetatable(o)==_EMPTYMT then
    return 'empty'
  else
    return type(o)
  end
end

This of course would have to be:

 do
  local oldtype=type
  type=function(o)
    if getmetatable(o)==_EMPTYMT then
      return 'empty'
    else
      return oldtype(o)
    end
  end
end

Otherwise you end up in an infinite tail-call loop :)