[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: making vars local by default
- From: Dominik Wagner <dwagner@...>
- Date: Sat, 26 May 2001 12:05:20 +0200
ReSent-From: dominik-wagner <dominik-wagner@gmx.net>
ReSent-To: lua-l@tecgraf.puc-rio.br
--- In lua-l@y..., "J. Perkins" <jason@3...> wrote:
> It's starting to become apparent to me that life would be easier if new
> variables were
> local by default, instead of global. I'm about to go online and look for
IMHO you just think that life would be easier. My POV is different. The
first step with switching this behavior would be to introduce somenthing
like a global statement to declare global variables. And thats wheres
the problem. If you write global to what variable do you refer: to the
upmost global scope variable or to a variable made local in a previous
function? If you want to preserve the meaning of the keyword you have
refer to the upmost global scope variable. and that is killing the many
scopes you need for e.g. a Sandbox Environment where you just overwrite
global variables with local ones and then call other function which
themselfes can't acces the more global one. In PHP this is solved this
way and it's just a pain in the ass.
And if you make global declared variables behave like the non-declared
variables now, then you just don't fit into the meaning of the word
global. IMO a statement like subglobal, or previously_used would be
needid which is totally over the top.
The better solution is the local variant, because local variables are
just local, and start here. non-declared variables have scope starting
anywhere or maybe at this point in the function.
regards,
Dominik Wagner
--
-- mailto:dominik-wagner@gmx.net -- mailto:dwagner@innnet.de --
-- http://www.arcsite.de/hp/dragon/ -- 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
The imaginary friends I had as a kid dropped me because their friends thought I didn't exist. Aaron Machado