Skip to content
This repository has been archived by the owner on May 4, 2024. It is now read-only.

RFC: Add debug.getmetatable and debug.setmetatable #39

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ccuser44
Copy link

Add debug.getmetatable and debug.setmetatable

Summary

Add debug.getmetatable and debug.setmetatable functions which have the same behavior as getrawmetatable and setrawmetatable.

Motivation

Vanilla Lua uses debug.getmetatable and debug.setmetatable, some executors have them also. It would be good to have more compatibility with vanilla Lua as it's odd that there are functions that to the exact same thing as their vanilla Lua counterparts but have a different name.

Design

  • debug.getmetatable functions the same as getrawmetatable. ie. it always returns the real metatable of the object even if it is spoofed via __metatable metamethod.
  • debug.setmetatable functions the same as setrawmetatable. ie. it always sets the real metatable of the object even if it is spoofed via __metatable metamethod.

Drawbacks

Not much, have to add both the functions to the debug. library.

Alternatives

The alternative is just to use getrawmetatable and setrawmetatable. The impact of using them is small but it's still a good thing to have functions be on par with vanilla Lua.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant