lua-users home
lua-l archive

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


According to the context of the book, "company" is a global library,
like "math", "string" and so on.

For details, see <<programming in Lua, 4th edition>> page 39.

On Sun, Oct 11, 2020 at 6:06 PM Robert Burke <sharpobject@gmail.com> wrote:
>
> If "company" is a local variable, you have its value on the stack. If it is global, you will need a table lookup to find it.
>
> On Sun, Oct 11, 2020, 18:20 孙世龙 sunshilong <sunshilong369@gmail.com> wrote:
>>
>> Hi, list
>>
>> How many table accesses caused by this expression:
>>
>> zip = company and company.director and
>> company.director.address and
>> company.director.address.zipcode
>>
>> As per the book(programming in Lua, 4th edition), the answer is 6.
>> Why?
>> For 0+1+2+3?
>>
>> Why "company" does not perform a table access?
>> Could somebody shed some light on this question?
>>
>> Best regards.
>> Sunshilong