• 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: global variables
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: global variables


  • Subject: Re: global variables
  • From: David Crowe <email@hidden>
  • Date: Wed, 17 Jul 2013 14:04:52 -0600

One problem with global variables is usually one of scope. If you re-use one of the names inside a function you can end up with mysterious problems when you end up using a local variable instead of global.

It is also difficult to see exactly where a global variable is set/modified/read. However, if the variables are initialized once, never modified, and only used by functions, then this should not be a problem.

Another option would be to create a large associative array and pass that around.

- David



> ----------------------------------------------------------------------
>
> Message: 1
> Date: Wed, 17 Jul 2013 13:49:47 -0500
> From: Jim Brandt <email@hidden>
> To: email@hidden
> Subject: global variables
> Message-ID:
> 	<email@hidden>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Is there a downside to using global variables?
>
> I have several lists of data that I need across several handlers. This data
> has been loaded from several .plist files in the main script. I then need
> this data in the handlers being called by the main script.
>
> Am I better off making the lists global at the top level and then have them
> available in the handlers or re-reading the .plist files in each handler or
> pass them in through the argument list (I really don't want to do this
> because the argument list gets quite long)?
>
> Are the significant advantages of one method over another?
>
> TIA,
>
> Jim Brandt


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden


  • Prev by Date: Re: global variables
  • Next by Date: Re: global variables
  • Previous by thread: Re: global variables
  • Next by thread: Re: global variables
  • Index(es):
    • Date
    • Thread