如何巧妙绕过Lua中的__metatable属性实现长尾词查询?
- 内容介绍
- 文章标签
- 相关推荐
本文共计216个文字,预计阅读时间需要1分钟。
想了解是否有绕过 `__metatable` 方法的技巧。我知道没有直接的方法,但我在尝试时,`__metatable` 会阻止这种操作。试试在表中添加一个名为 `__metatable` 的字段:`setmetatable(t, customTable)`
我想知道是否有办法逃避__metatable元方法.我知道没有一个,但我正在尝试做这样的事情,但显然__metatable会阻止这种情况发生:-- pretend that there is a __metatable field given to a table setmetatable(_G, {__index = {None="No indexes"}}) -- error: (the string given to the __metatable metamethod)
我在这里尝试做的只是逃避__metatable字段,只是允许自己在_G上设置metatable,它已经有一个.
我知道这是不可能做到的,但是我想问一下是否还有机会绕过?
__metatable的重点是保护.调试库绕过了这种保护(和其他),当然应该谨慎使用.
本文共计216个文字,预计阅读时间需要1分钟。
想了解是否有绕过 `__metatable` 方法的技巧。我知道没有直接的方法,但我在尝试时,`__metatable` 会阻止这种操作。试试在表中添加一个名为 `__metatable` 的字段:`setmetatable(t, customTable)`
我想知道是否有办法逃避__metatable元方法.我知道没有一个,但我正在尝试做这样的事情,但显然__metatable会阻止这种情况发生:-- pretend that there is a __metatable field given to a table setmetatable(_G, {__index = {None="No indexes"}}) -- error: (the string given to the __metatable metamethod)
我在这里尝试做的只是逃避__metatable字段,只是允许自己在_G上设置metatable,它已经有一个.
我知道这是不可能做到的,但是我想问一下是否还有机会绕过?
__metatable的重点是保护.调试库绕过了这种保护(和其他),当然应该谨慎使用.

