[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Web development with Lua
- From: HyperHacker <hyperhacker@...>
- Date: Tue, 18 Oct 2011 22:51:33 -0600
On Tue, Oct 18, 2011 at 19:48, Tang Daogang <daogangtang@gmail.com> wrote:
>
>
> On Wed, Oct 19, 2011 at 8:33 AM, Philipp Janda <siffiejoe@gmx.net> wrote:
>>
>> On 18.10.2011 05:53, Tang Daogang wrote:
>>>
>>> On Tue, Oct 18, 2011 at 11:04 AM, Norbert
>>> Kiesel<nkiesel@tbdnetworks.com>wrote:
>>>
>>> ;) I am sorry, Bamboo relies on lglib
>>> (https://github.com/daogangtang/lglib),
>>> in which I override the __add method with ..
>>>
>>
>> Not a good idea if your strings look like numbers:
>>
>> $ cat > adds.lua
>> local mt = getmetatable( "" )
>> mt.__add = function( a, b )
>> return a .. b
>> end
>> print( "1" + "2" )
>> ^D
>>
>> $ lua adds.lua
>> 3
>>
>> Lua tries to convert arguments of '+' to numbers and apply numeric
>> addition *before* metamethods are involved.
>>
> That is true. I think this is lua's flaw, thanks for your mention, let me
> think how to treat this case.
>
>>
>> Philipp
>>
>>
>
>
>
> --
> Nothing is impossible.
>
>
This is by design. Metamethods are fallbacks, not overrides.
--
Sent from my toaster.
- References:
- Web development with Lua, Luciano de Souza
- Re: Web development with Lua, Sebastien Lai
- Re: Web development with Lua, Tang Daogang
- Re: Web development with Lua, jyf
- Re: Web development with Lua, Victor Young
- Re: Web development with Lua, Norbert Kiesel
- Re: Web development with Lua, Victor Young
- Re: Web development with Lua, Norbert Kiesel
- Re: Web development with Lua, Tang Daogang
- Re: Web development with Lua, Philipp Janda
- Re: Web development with Lua, Tang Daogang