[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Globals (more ruminations)
- From: "Juri Munkki" <jm_list@...>
- Date: Fri, 16 Jul 2010 12:32:24 +0300
On Fri, July 16, 2010 11:49 am, Jonathan Castello wrote:
> I personally haven't had too many nightmares from misspelling variable
> names, but under my suggestion you could likely list out the
> environment's entries and see if anything's there that shouldn't be.
> It would be easier than looking through a potentially cluttered shared
> environment like we have by default now, and probably easier than
> reading through the file to spot a problem.
>
> If you want strict declaration of variables in the environment, it
> shouldn't be hard to create a strict.lua-alike that requires
> declarations with a global() function before they can be assigned to.
Strict.lua only checks code that executes. In order to test your code for
missing local declarations, you have to make sure that all your code has
been tested while strict.lua is active. If you use strict.lua all time
while developing code, it's probably not a problem.
However, if you only use strict.lua occasionally, some errors might slip
by. For instance, you might have a function where you use a variable
called "parts" and if you forget to make it a local variable, things work
fine until the day you use the same variable again in another module and
they both try to use it (for different purposes).
I'm all for adding the "global" keyword to the language. It's optional, so
no one is ever forced to use it.
--
Juri Munkki
- References:
- Re: Globals (more ruminations), Mark Hamburg
- Re: Globals (more ruminations), Roberto Ierusalimschy
- Re: Globals (more ruminations), Geoff Leyland
- Re: Globals (more ruminations), Alexander Gladysh
- Re: Globals (more ruminations), Roberto Ierusalimschy
- Re: Globals (more ruminations), Juri Munkki
- Re: Globals (more ruminations), Roberto Ierusalimschy
- Re: Globals (more ruminations), Patrick Donnelly
- Re: Globals (more ruminations), Roberto Ierusalimschy
- Re: Globals (more ruminations), Geoff Leyland
- Re: Globals (more ruminations), Roberto Ierusalimschy
- Re: Globals (more ruminations), Geoff Leyland
- Re: Globals (more ruminations), joao lobato
- Re: Globals (more ruminations), Miles Bader
- Re: Globals (more ruminations), Jonathan Castello
- Re: Globals (more ruminations), Miles Bader
- Re: Globals (more ruminations), Jonathan Castello