[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: One more item to the collection of Lua hate-speech
- From: HyperHacker <hyperhacker@...>
- Date: Sun, 4 Jul 2010 08:01:46 -0600
On Sun, Jul 4, 2010 at 06:29, Vaughan McAlley <vaughan@mcalley.net.au> wrote:
> On 4 July 2010 12:50, KHMan <keinhong@gmail.com> wrote:
>>
>> An impossible social issue to settle, I rather think, since the range of
>> skills is very wide. Like many Perl users, I can only type away on a
>> keyboard in a subset of Perl, so that's one unintended way of allowing
>> beginner and expert use to coexist. Can one say I am using precisely the
>> same Perl? Maybe not, since I am practising TIMTOWTDI without any skills to
>> code in "other ways". This would also not work with a small fat-free
>> language.
>>
>>
>
> Looking back at my first Warcraft addon, there are a few locals within
> functions, but every other variable was a (mostly) distinctively named
> global. Performance was fine. I was able to learn and get to like Lua
> before grasping the subtleties of lexical scoping, which I personally
> appeciate- friendly for beginners and powerful for advanced users.
>
> Vaughan
>
I doubt you'd see a noticeable performance hit from using globals,
except perhaps in extremely CPU-intense scripts that are doing a lot
of calculations (in which case you may want to move those functions to
a C module). The real issues as I see it are polluting the namespace
and not keeping your code self-contained. If your module is using a
bunch of globals, you have the potential for name conflicts, possible
security issues (one script "breaks into" a more privileged script by
messing with its state), and other bugs.
Generally, a module should define/return a single global table
containing all of their functions, constants etc. Of course, there are
exceptions to every rule.
--
Sent from my toaster.
- References:
- One more item to the collection of Lua hate-speech, Alexander Gladysh
- Re: One more item to the collection of Lua hate-speech, Luiz Henrique de Figueiredo
- Re: One more item to the collection of Lua hate-speech, Petite Abeille
- Re: One more item to the collection of Lua hate-speech, Javier Guerra Giraldez
- Re: One more item to the collection of Lua hate-speech, Alexander Gladysh
- Re: One more item to the collection of Lua hate-speech, liam mail
- Re: One more item to the collection of Lua hate-speech, David Manura
- Re: One more item to the collection of Lua hate-speech, David Kastrup
- Re: One more item to the collection of Lua hate-speech, David Manura
- Re: One more item to the collection of Lua hate-speech, KHMan
- Re: One more item to the collection of Lua hate-speech, Vaughan McAlley