lua-users home
lua-l archive

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



On Mittwoch, April 17, 2002, at 06:50 , Edgar Toernig wrote:

Luiz Henrique de Figueiredo wrote:

I'm not sure if the global statement is the right thing.

It's a new thing, and certainly not simple (or at least capable of being used in quite complicated ways), but we thing it does address a need. Or doesn't it?
(The only snag right now is the need for "predeclarations".)

It does more. As I see it, people want some kind of protection against mistyped variable names. One fundamental part of that is a way to easily know which globals are exported by a module/file/library. That is not addressed with the current global statement (the 'snag' you mention: the core wants to export
globals without the need to import each one individually).

The "global" declaration is for sophisticated uses, but I don't think it makes the language more difficult: it just let's you do complicated scope control.

And that is what I fear. The simple 'global <name>' is easy and I have no problem with that. A method to let the compiler check for undefined names.

But the 'global ... in <table>' is something completely different. It doesn't address the mentioned 'need'. It introduces a method for complicated dynamic variable bindings and my fear is that you get even more complex rules (Which identifier accesses which object?) than the rules in C++. Reading sources
may become a nightmare.

I aggree. i have a very strange feeling about this global in statement. What i defininatley don't like is the problem with old and other code that relies on the "normal" way of globals.
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.
That's (as far as i can see now) a bloody mess.
I want to do reusable, as indepent libraries as possible!
And what use is a global-control when you can't use it if you want to use this or that library or vice versa. Or am i just to blind to see the simple solution here?

Another thing i don't grasp at the moment is how
global in nil
can be used at all?
after that you have no access to the original functions, or have you?
or do you have to do something like this:
global strfind,print
global in nil

and then strfind and print can be used?

In fact, I think that the 'global ... in <table>' has nothing to do with globals any more. It's a shorthand to access table fields (Pascal's with-statement).
A completely different topic.


Dominik

-- 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