[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Four paradigms for programming Lua apllications
- From: Eduardo Tongson <propolice@...>
- Date: Tue, 1 Apr 2014 16:46:42 +0800
On Mon, Mar 31, 2014 at 5:51 PM, steve donovan
<steve.j.donovan@gmail.com> wrote:
> On Mon, Mar 31, 2014 at 11:41 AM, Peter Melnichenko
> <petjamelnik@yandex.ru> wrote:
>> I'm wondering what is the current policy on localizing globals in modules(e.g. `local type = type; local tinsert = table.insert` etc). I never did it before because the performance gains were usually negligible, but there was a point raised that it should be done to protect modules against monkey-patching.
>
> Key word is 'usually' ;) So then it seems like premature
> optimization to localize all globals?
>
> I've fallen into the habit of doing this - it does document what
> libraries a module uses, although a little ... tedious to type.
> (Little macros can be written if you use a clever editor)
>
> As for monkey-patching, as a community we don't like it much,
> particularly for public-facing modules. It has caused great grief to
> the Rubyists...who would be so mad as to redefine 'table.insert'?
>
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?