lua-users home
lua-l archive

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


On Thu, Nov 24, 2011 at 8:19 AM, Roberto Ierusalimschy
<roberto@inf.puc-rio.br> wrote:
>> But I checked in the manual, and was surprised to note that [string.len] is not
>> marked as deprecated, not even in Lua 5.2.
>> To Roberto: is this function still maintained for compatibility, or
>> for another reason ?
>
> Mostly for compatibility (and because we did not notice it could
> be removed ;)

In 5.2, you also have the new `rawlen` function (why isn't it listed
as new in [1]?), which works on both tables and strings.  This ignores
metamethods, but __len is ignored for strings.  Penlight has a module
that provides functional forms of all operators [2], which does invoke
metamethods.

[1] http://www.lua.org/work/doc/
[2] http://penlight.luaforge.net/api/modules/pl.operator.html#len