lua-users home
lua-l archive

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



On Donnerstag, April 18, 2002, at 07:29 , lua-l@yahoogroups.com wrote:

If i use e.g.
global in nil

then any code that is dofiled or something has to obey to this, or it
won't work. quite a mess for any Standard Libraries.
Libraries suddenly depend on how the user wants to handle globals.

No: "global" respect scopes. dofile'd programas are not executed in the same
scope of the calling program; dofile is not include.


so global doesn't affect dofile statements at all? so when i do:
a=123
dofile('blah.lua')
do
   global in T
   a=12
   dofile('blah.lua')
end

where blah.lua is the following:
print(a)

then this example would print out:
123
123

?
Really? Interesting. so i can't use global for sandboxes in which dofile would be allowed?

But i still think the following:
The beauty in lua lies in the simplicity which still provides uncomplicated and powerful ways of doing things. This global statement somehow doesn't fit. it really looks like an complex and complicated beast albeit the "simple" syntax.

Dom


-- http://www.DasGenie.com/ --
AIM: DasGenieDotCom - ICQ: 22369156

"Glück ist eine Verpflichtung. Wir sollten uns für das Glück entscheiden.
Wir sollten daran arbeiten. Und dabei sollten wir denen, die uns am
nächsten stehen, und auch jenen, die nur zufällig unseren Pfad kreuzen,
eine Hilfe sein, damit auch sie ihr Glück finden." - Richard Koch