lua-users home
lua-l archive

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


On Fri, Apr 26, 2013 at 8:38 AM, Steve Litt <slitt@troubleshooters.com> wrote:
> On Fri, 26 Apr 2013 13:13:33 +0200
> Thomas Jericke <tjericke@indel.ch> wrote:
>
>> On 04/25/2013 10:54 PM, Steve Litt wrote:
>> > I would too. If I really want something to be global, I'll
>> >
>> > global myvar = 0
>> >
>> > It's not like I'm going to have 40 globals anyway, so this won't be
>> > much writing.
>> >
>> To me there are still some problems regarding scoping with this,
>> consider:
>>
>> if someboolean then
>>      global myvar = 0
>> end
>>
>> print(myvar) -- Is this valid?
>
> Why in the world would anyone do this? I can't think of any reason for a
> global variable's existence to be conditional.
>
>
> SteveT
>
> Steve Litt                *  http://www.troubleshooters.com/
> Troubleshooting Training  *  Human Performance
>

The "why" doesn't really matter, I think. The question is how
well-defined the behavior is (even if it's not necessarily useful) so
that a program has deterministic, understandable behavior in the face
of someone even accidentally doing something like this.

/s/ Adam