lua-users home
lua-l archive

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


this may help,

http://lua-users.org/wiki/LocalByDefault

On Thu, Aug 7, 2014 at 10:18 AM, Mason Mackaman <masondeanm@aol.com> wrote:
> So could I have an example of where one would want or need to declare a global variable?
> On Aug 7, 2014, at 12:05 PM, Elias Barrionovo <elias.tandel@gmail.com> wrote:
>
>> On Thu, Aug 7, 2014 at 2:02 PM, Coda Highland <chighland@gmail.com> wrote:
>>> But you're exactly right -- you could do that, and many people DO
>>> exactly that as an optimization.
>>
>> More than that; it's generally considered a bad habbit to use globals,
>> especially when creating libraries, or otherwise there's a good chance
>> there will be name conflicts.
>>
>> Now why lua variables are global by default is something that shows up
>> quite often here on the mailing list. If you search the lua-l archives
>> you'll se a lot of discussion about that. Key search terms would be
>> "global by defaul", "local by default" and "lexical scoping".
>>
>> --
>> NI!
>>
>> () - www.asciiribbon.org
>> /\ - ascii ribbon campaign against html e-mail and proprietary attachments
>>
>
>