[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: lpeg question
- From: Dibyendu Majumdar <mobile@...>
- Date: Tue, 13 Mar 2018 20:33:31 +0000
On 13 March 2018 at 20:25, Charles Heywood <vandor2012@gmail.com> wrote:
> On Tue, Mar 13, 2018 at 3:22 PM Dibyendu Majumdar <mobile@majumdar.org.uk>
>> I found that Ravi cannot execute lpeg tests. Upon further
>> investigation, it seems the issue is because Ravi expects '#' operator
>> to return an integer result, but lpeg defines a metamethod for this
>> operator that returns a userdata object.
>>
>> Is this a violation of the contract for # operator, or is my
>> understanding incorrect about the result of this operator?
>>
> To quote the manual:
>
>> A program can modify the behavior of the length operator for any value but
>> strings through the __len metamethod (see §2.4).
>
> This does not require that the value be an integer, but instead "any value".
>
I don't interpret the manual that way. I read that as saying that you
cannot modify the length operator for a string. But __len is defined
as a length operation, is it not?
And above is in section 3.4.7 by the way.