lua-users home
lua-l archive

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


Doesn't the % character refer to an upvalue in Lua 4?
Lua 5 removed the need for explicit noting of upvalue identifiers, and
% is now modulus.

2008/5/8 Till Harbaum / Lists <lists@harbaum.org>:
> So simple ...
>
> Thanks, i obviously was just blind.
>
> Till
>
> Am Donnerstag 08 Mai 2008 schrieb Roberto Ierusalimschy:
>> > 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
>>
>
>
>