lua-users home
lua-l archive

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


> i am trying to extend the tostring function to do something special
> for my own special use tables. I found some example using the syntax
> below:
> 
> function tostring(a)
>    -- do something for special tables ...
>    -- otherwise call original function:
>    return %tostring(a)
> end
> 
> But this gives me an error for the % character. Omiting the % results in an
> endless loop for obvious reasons ...
> 
> How is this done?

  local oldtostring = tostring
  function tostring(a)
     -- do something for special tables ...
     -- otherwise call original function:
     return oldtostring(a)
  end


-- Roberto