• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Recursion script which doesn't?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Recursion script which doesn't?


  • Subject: Re: Recursion script which doesn't?
  • From: Paul Berkowitz <email@hidden>
  • Date: Fri, 06 Apr 2001 16:22:16 -0700

On 4/5/01 3:19 PM, "Charles Arthur" <email@hidden> wrote:

>> I'm not sure if using 'lastrundate' as a parameter instead of a global is
>> actually more efficient, but it's generally considered to be better
>> practice.
>
> Could I be tedious and ask particulary why?


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.

What I do see is that the general principle of Occam's razor - in this case
"why use a blunderbuss when a penknife will do?" - would apply here. If you
just need to refer to a variable in one or two handlers, why make it apply
everywhere? (Although I still don't see what harm it does, normally, it does
"feels neater" just to use it where necessary.) I have used globals to good
effect when accumulating lists in repeated iterations of many different
handlers - although even there you can pass the list back and forth as a
parameter (to) and "return" (from) the handlers instead if you prefer.

--
Paul Berkowitz


  • Follow-Ups:
    • Re: Recursion script which doesn't?
      • From: John W Baxter <email@hidden>
    • Re: Recursion script which doesn't?
      • From: Timothy Bates <email@hidden>
References: 
 >Re: Recursion script which doesn't? (From: Charles Arthur <email@hidden>)

  • Prev by Date: Stable, CPU-friendly periodic task scheduling
  • Next by Date: Re: RA-Status work-around
  • Previous by thread: Re: Recursion script which doesn't?
  • Next by thread: Re: Recursion script which doesn't?
  • Index(es):
    • Date
    • Thread