lua-users home
lua-l archive

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


On 2010-07-09, Matthew Wild <mwild1@gmail.com> wrote:
> On 9 July 2010 14:18, steve donovan <steve.j.donovan@gmail.com> wrote:
>> On Fri, Jul 9, 2010 at 1:49 PM, Antonio Vieiro <antonio@antonioshome.net>
>> wrote:
>>> Excuse my ignorance, but C has no namespaces and there's no problem in
>>> building large applications on top of it, right?
>>
>> Very true, but C requires everything to be declared up-front.  Lua
>> will automatically declare an unknown variable to be global
>> (global-as-default), so any misspelling will cause a runtime problem
>> since the new variable will have the value 'nil'.  (Perhaps it
>> wouldn't be so bad if the initial value was something like
>> 'undefined').
>>
>
> In my opinion, it would. I really dislike the distinction between
> "nothing" and "nothing" in Javascript.
>
>> It's a question of scale.  A 100-line script does not have to worry
>> too much about locals and globals, but a 100Kloc program has to be
>> more careful, especially with global-as-default.
>>
>
> I think I wouldn't mind a 'global' keyword which imports selected
> variables from the global environment, similar to (shudder) PHP.
>
> Matthew
>

I've always thought PHP's method was somewhat backward. It can be
confusing for newbies, and I'm always forgetting to add global imports
as I use them.
(That, and do we really want Lua to be known as "the PHP of embedded
languages"? *shudder*)

-- 
Sent from my toaster.