lua-users home
lua-l archive

Re: Equivalent to table.move for Lua 5.1

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


On 16/02/2021 06:57, Hisham wrote:
On 2021年2月14日 at 12:36, Lorenzo Donati <lorenzodonatibz@tiscali.it>
wrote:
Hi folks!
Trying to spare a little time here.
I'm writing a little library for my stuff which will make use of Lua 5.3
table.move but should also be usable with Lua 5.1.
I could write an ad-hoc Lua 5.1-compatible fallback function, but I'd
prefer not to waste time reinventing the wheel (and thoroughly testing
it with all corner cases)!
So I thought that maybe a /well-tested/ /pure-Lua/ replacement for
table.move has already been posted somewhere that I could copy-paste
into my code.
I don't care if it is a bit slow (as long as it is not utterly
wasteful), but it should be well tested and/or "peer-reviewed" and
should replicate table.move semantics in the details (I wouldn't want
unexpected differences between Lua 5.3 and Lua 5.1 scripts).
Any pointers appreciated.
What you're looking for is the compat-5.3 library:
https://github.com/keplerproject/lua-compat-5.3
It includes based implementations of many compatibility functions for
performance but many functions (including table.move) have pure-Lua
fallbacks. If you're using LuaRocks, including compat53 as a dependency and
a `require "compat53"` in your project is sufficient (it is a no-op in Lua
5.3+), no need to resort to copy-pasting.
-- Hisham
Thank you Hisham!
No, I don't use luarocks.
I have a very personalized "install" of Lua (just compiled from PUC source plus manually installed libraries) that can be copied and carried on an external HDD/SSD/pendrive and run from there (under Windows).
I'll look and see if I can easily take the code from the link you provided.
Thanks again!
-- Lorenzo

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