[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Globals (more ruminations)
- From: David Kastrup <dak@...>
- Date: Mon, 12 Jul 2010 08:06:52 +0200
caseyh@istar.ca writes:
> Quoting Geoff Leyland <geoff_leyland@fastmail.fm>:
>
>> On 12/07/2010, at 5:14 AM, Roberto Ierusalimschy wrote:
>>
>>> I still think the main problem is non-intended assignment to globals,
>>> which creates hard-to-find bugs. The simple policy of requiring a global
>>> declaration to assign to globals would force programmers to consider
>>> whether they really want a global variable.
>>
>> One possible downside of this is that this very simple Lua program:
>>
>> a = "Hello World"
>> print(a)
>>
>> becomes:
>>
>> global a = "Hello World"
>> print(a)
>>
>> (or "local a..."). Does this make Lua harder to learn?
>
> Arrrrrrrgh!
>
> I thought ONLY within a function one would have to use the "global"
> prefix and not use the prefix at the top level.
Is there a top level?
--
David Kastrup