lua-users home
lua-l archive

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


2014-04-01 10:46 GMT+02:00 Eduardo Tongson <propolice@gmail.com>:

> What are the drawbacks of doing:
>     local table = table
>     ...
>     table.concat(t)
>
> instead of:
>
>     local concat = table.concat
>     ...
>     concat(t)
>
> Does it exactly have the same effect?

No.

If the program that requires your module says:

   table.concat = nil

in the first case your module will fail, because your local `table`
still denotes the same table whose `concat` entry has been zapped.

In the second case, your module will work because your local
`concat` still refers to the original `concat` which the calling
program no longer can access directly.