lua-users home
lua-l archive

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


So does some equivalent of "local getmetatable('').__index=_ENV.string” execute before the program starts?
On Aug 7, 2014, at 12:22 PM, Mason Mackaman <masondeanm@aol.com> wrote:

> This statement is on hold while I digest Elias’ post. I hadn’t seen it when I said that.
> On Aug 7, 2014, at 12:12 PM, Mason Mackaman <masondeanm@aol.com> wrote:
> 
>> AHHH! but I thought the only thing the metatable did was tell Lua to get _ENV.string whenever you try to index ’str’!? Sorry if I’m being annoying, I’m just trying to understand.
>> On Aug 7, 2014, at 11:52 AM, Coda Highland <chighland@gmail.com> wrote:
>> 
>>> On Thu, Aug 7, 2014 at 9:47 AM, Mason Mackaman <masondeanm@aol.com> wrote:
>>>> I think the reason I’m still confused is I’m not understanding how this works. I figured when you do str:len(), you still have to access the global ‘string’ table, because that’s what the __index metamethod is for ‘str’s metatable. In which case it would be more work. Are you saying str:len() retrieves the ‘len' function without having to get _ENV.table?
>>> 
>>> That's exactly what's being said here. Going from str to str's
>>> metatable doesn't involve any external lookups at all.
>>> 
>>> /s/ Adam
>>> 
>> 
>> 
> 
>