Re: Recursion script which doesn't?
Re: Recursion script which doesn't?
- Subject: Re: Recursion script which doesn't?
- From: John W Baxter <email@hidden>
- Date: Fri, 6 Apr 2001 22:09:28 -0700
At 16:22 -0700 4/6/01, Paul Berkowitz wrote:
>
Well, this will be interesting. 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, just like the things that your
>
parents told you were "bad" when you were 5 years old. I've been wondering
>
if it's really no more than a superstition and habit, since I've never seen
>
anything bad result from using globals.
It's taught in computer class because experience in the days of routine use
of globals showed it *could* be a nightmare.
Plus, globals ARE a nightmare in a world of multiple threads of execution
using the same set of globals. Part of the reason process switching is so
clunky in Mac OS 9 down to System 5 or 6 is the vast collection of globals
which began life reasonably: they were how the system and the
one-and-only-application-which-could-run-at-one time communicated. That
works, in the one-and-only... world. (Initially, Finder quit having
informed the system what was to run in its place...the system launched
Finder when that thing quit. And Finder couldn't find anything...it merely
let you find.)
Naturally, the pendulum swung the other way, to "never use globals." And
indeed there are languages in which it's not possible to use globals.
Except that it is...they are there in disguise as attributes of some
"master" object.
So I try not to use globals, but I use them when it clearly makes something
simpler to do. Or in quick and dirty code I'm going to throw away before
the Global Police show up at the door.
GoTo is another one...which we don't have in AppleScript. Except that we
do: exit repeat is nothing but goto spelled another way and somewhat
controlled (it can only go one place). (My first boss at NCR was convinced
he could prove that the source language goto could be totally replaced by
the comefrom, and I suspect he was right. But there wasn't time to play
with it.)
--John
--
John Baxter email@hidden Port Ludlow, WA, USA