lua-users home
lua-l archive

Re: lpeg question

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


> 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?
I am not sure what you mean by "__len is defined as a length operation".
It is *called* the length operator, but a name does not give its
semantics. __add is also related to the "addition operation", but that
name does not imply that it is an addition.
Note the following:
1) The __eq metamethod, which always returns a boolean, says so:
 "The result of the call is always converted to a boolean."
2) The API for the length operation does not return a number, but a
Lua value. (The same is true for addition, but not for comparisons.)
-- Roberto

AltStyle によって変換されたページ (->オリジナル) /