• 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: AS Library Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AS Library Question


  • Subject: Re: AS Library Question
  • From: Shane Stanley <email@hidden>
  • Date: Thu, 17 Dec 2015 10:18:19 +1100

On 17 Dec 2015, at 2:54 AM, has <email@hidden> wrote:
>
> > The solution is to basically to be aware of it, and probably avoid properties within libraries where they're not really needed. And you can do things like add some kind of initialization handler that scripts should run first before they call others.
>
> Not a great idea, as now you've got several scripts contesting over who set what last.

That's what the initialization handler would do; set properties back to defaults.

> > There are also cases where a persistent lib property makes sense. Something like a number formatter in an ASObjC-based lib, or simply where you scripts to share some info.
>
> For the first, you'd probably use OOP to create and return your custom number formatter, which you then retain in your own code while using it.

Except I'm talking about using it within multiple scripts.

> The one thing you might safely keep in such a library is a cache of, say, previously created instances, if creating those instances is a particularly expensive process

See above.

> > And if you don't run scripts from within other apps, you can just ignores it.
>
> Unsafe advice: even if your current usage avoids the problem, you should be including cautionary comments at the top of such libraries warning future maintainers that the library contains mutable state and thus will cause obscure and hard-to-identify malfunctions should two completely unrelated scripts try to load and use it at the same time.

And presumably we should put the same comment in our scripts every time we use text item delimiters.

--
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>


 _______________________________________________
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


References: 
 >Re: AS Library Question (From: has <email@hidden>)

  • Prev by Date: Re: Pulling Data from AppleScript
  • Next by Date: Re: Pulling Data from AppleScript
  • Previous by thread: Re: AS Library Question
  • Next by thread: Re: AS Library Question
  • Index(es):
    • Date
    • Thread