[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Why are people so afraid of globals?
- From: Mark Hamburg <mark@...>
- Date: Fri, 9 Jul 2010 09:21:22 -0700
On Jul 9, 2010, at 7:00 AM, Roberto Ierusalimschy wrote:
> The problem that concerns me is assignment to globals meant to be
> locals, either because someone only forgot to add 'local' or because he
> knows no better. This kind of bug is easy to write and hard to find.
The Smalltalk and Ruby fix for that: Variable name formatting determines the namespace in which to look.
This causes a certain amount of shuddering when I think about it, but it does mean that globals look like globals and locals look like locals. I think it also has precedence in Common LISP's format for naming dynamically scoped variables.
But it also fights with the various environment switching techniques like module(). That, however, gets us back to the observation that the 5.2work3 change to use the _ENV variable makes it clearer in the code what code is working at chunk scope and what code is working in some other environment.