• 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: what is the best way to 'unset' a variable
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: what is the best way to 'unset' a variable


  • Subject: Re: what is the best way to 'unset' a variable
  • From: John W Baxter <email@hidden>
  • Date: Fri, 22 Mar 2002 22:07:38 -0800

At 19:16 -0800 3/22/2002, Paul Berkowitz wrote:
>Even with globals, which do still keep their value at the
>end of a script, until it's run again. They will _have_ to be reset by your
>script before they're used again. (Otherwise they would have errored
>"variable is not defined": the first time).
>
>In the case of properties, just reset them to whatever their initial value
>is at the top of the script. Although if you don't want properties to
>persist, why declare them as properties in the first place?
>
>there is no advantage or disadvantage to initializing x to any one of your
>options in preference to any other. And - as far as I know - no advantage to
>"unsetting" hem at all. Just leave them be.

If a global is large (a long string, etc), then there is an advantage to
clearing it before reaching the end of the script: the script file on disk
will be smaller if the large string is "cleared" than if it isn't. I
think: experiment.

I'd clear the value based on what's there: if it's a string, I would use
""; if it's a number I wouldn't bother, but if I did I'd use 0 or 0.0; if
it's a --possibly large-- list or record I'd use {}, etc.

Missing value might (or might not) be four bytes shorter than "" or 0, and
8 bytes shorter than 0.0, but who cares...we're after the difference
between 100K and a few bytes, not a 4 byte difference.

--John

--
John Baxter email@hidden Port Ludlow, WA, USA
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: what is the best way to 'unset' a variable
      • From: Bill Hoffman <email@hidden>
References: 
 >Re: what is the best way to 'unset' a variable (From: Paul Berkowitz <email@hidden>)

  • Prev by Date: Re: Stumped with open file
  • Next by Date: [OS X]getting email addresses with AppleScript
  • Previous by thread: Re: what is the best way to 'unset' a variable
  • Next by thread: Re: what is the best way to 'unset' a variable
  • Index(es):
    • Date
    • Thread