lua-users home
lua-l archive

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


Thanks for sharing, I know how to do if I want to solve "table.getn" issue to use new version Lua.


From: Dirk Laurie <dirk.laurie@gmail.com>
To: Lua mailing list <lua-l@lists.lua.org>,
Date: 2018/02/08 14:47
Subject: Re: Fosdem talk on pain of moving from Python 2.x to 3.x





2018-02-08 8:18 GMT+02:00 <Apeng.Xiong@alitech.com>:
>
> when I want to migrate to the new Lua, I faced the big problem is "table.getn" is no longer exist. so I still use Lua 5.1.
>

That is not Lua 5.1, that is Lua 5.0. To get it under 5.1, you need to
have compiled with the compatibiliy option,[1] which is the default,
so that's why people think table.getn is 5.1.

Anyway, it is the easiest possible thing to supply.

table.getn = function(t) return #t end

[1] "Function table.setn was deprecated. Function table.getn
corresponds to the new length operator (#); use the operator instead
of the function." From the "Changes in the Libraries" section of the
Lua 5.1 manual.