Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
ANRC Universe
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Module talk:TableTools
(section)
Add topic
Module
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
Add topic
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Infinite loop in deepCopy == There's a bug in the <code>deepCopy</code> function which manifests with any kind of recursive table nesting. However, it's easy to fix, as you just need to cache the new copy in {{code|already_seen|lua}} before doing the {{code|pairs|lua}} loop, like this: <syntaxhighlight lang=lua> if type(orig) == 'table' then copy = {} already_seen[orig] = copy for orig_key, orig_value in pairs(orig) do copy[_deepCopy(orig_key, includeMetatable, already_seen)] = _deepCopy(orig_value, includeMetatable, already_seen) end if includeMetatable then local mt = getmetatable(orig) if mt ~= nil then local mt_copy = _deepCopy(mt, includeMetatable, already_seen) setmetatable(copy, mt_copy) already_seen[mt] = mt_copy end end else -- number, string, boolean, etc copy = orig end </syntaxhighlight> [[User:Theknightwho|Theknightwho]] ([[User talk:Theknightwho|talk]]) 13:03, 14 April 2024 (UTC) :{{re|Theknightwho}} You may want to propose such changes in the sandbox. [[User:Alexiscoutinho|Alexis Coutinho]] ([[User talk:Alexiscoutinho|talk]]) <sup>[''[[WP:PING|ping me]]'']</sup> 00:09, 23 April 2024 (UTC) ::@[[User:Alexiscoutinho|Alexiscoutinho]] I've updated <code>deepCopy</code> with a fix in the sandbox, and introduced various optimisations, but I haven't added <code>deepEquals</code> since I'm not sure whether the WP would want table metamethods to be respected when traversing over the tables. The Wiktionary version does a strict comparison (i.e. metamethods are ignored), but that's what makes sense for our needs; however, that might be unintuitive for users who want to compare frame argument tables, for instance. [[User:Theknightwho|Theknightwho]] ([[User talk:Theknightwho|talk]]) 16:05, 24 April 2024 (UTC)
Summary:
Please note that all contributions to ANRC Universe may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
ANRC Universe:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Module talk:TableTools
(section)
Add topic