Re: Recursion script which doesn't?
Re: Recursion script which doesn't?
- Subject: Re: Recursion script which doesn't?
- From: Timothy Bates <email@hidden>
- Date: Sat, 07 Apr 2001 14:07:51 +1000
On 7/04/2001 9:22 AM, "Paul Berkowitz" <email@hidden> wrote:
>
There are people, including some real experts here, who believe that globals
>
are dangerous, but I've never understood why. It seems to be something taught
>
in computer classes that stick with people to the ends of their lives
The problems are:
1. You cannot be sure when you execute, that someone else has left the
global in the state that you need it, or will not change it while you are
using it. Caching the old state and resetting it when you leave is even
worse.
2. You cannot be sure without manually checking, that you are not
accidentally using a variable declared elsewhere as global when you think
you only have local scope (this can be disastrous: think what happens when
handler a uses "f" as a loop counter and someone else is using it to store a
file name which they declared global so that a range of handlers could
access the file).
3. When you change the name of a variable, you have to change it in a range
of other places: tedious and error prone.
4. When you change the _type_ of a variable, it has unforeseeable
consequences.
By making objects (easy in AS), you avoid all of this. My current rule is,
when ever I need to make a global, create a script object.
tim