• 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: TIDs info summary
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: TIDs info summary


  • Subject: Re: TIDs info summary
  • From: bill fancher <email@hidden>
  • Date: Sat, 09 Nov 2002 11:18:14 -0800

On Friday, November 8, 2002, at 11:05 AM, Paul Skinner wrote:

I find only six separate entries in the ASLG on the text item delimiter property of the global variable applescript. Little enough that I can post it all here for those without a copy or motivation.

Thanks for that. I probably should have done it myself at the beginning of my little campaign.

The last four are index or appendix entries and the one of those on p.379 is just a summary of the main entry on p.210-211.

Some statements pertinent to the ongoing discussions...
1. ASLG p.70:This property defaults to an empty string.
( try to get the ascii number of the default contents of the TIDs )

2. ASLG p.210:You may want to use an error handler to reset the Text Item Delimiters property to its former value if an error occurs.
( In several places it is suggested that one reset the TIDs after changing them. Only in the most simplified example scripts are they changed and not reset. )

The only relevant mention I can find is the one you quote here, which I'd wouldn't call a suggestion to reset tid's. Did I miss something?

It might also be worth noting that there are two examples where text items delimiters are not "restored" (hardly something we'd expect if doing so is somehow mandatory or recommended) and two where they are (one is more about dealing with the hazards of try blocks, and the other is an example of getting and setting tid's, so setting them to their prior value is the motivation for getting them in the first place.)

3. ( my own ) Storing and restoring the TIDs is pointless if you specifically set them before each use.

Blasphemy! (Welcome brother.)

UNLESS you use handlers or loaded scripts or run script constructions. If you use any of these language features then it becomes important to store and restore the current TIDs within them in order to prevent these constructions from invisibly and perhaps unexpectedly altering the TIDs and generating unexpected results in the main script.

I might have said: If you do those things, then afterwards it's important to set tid's appropriately before using them.

In fact, any time you gain or regain program control tid's are indeterminate until you set them. Even if you've got a script as simple as

set s to text items of "abc"
display dialog items 1 through 2 of s as string

Someone else could write

set s to (load script yourScript)
set text item delimiters to "z"
run script s

Guess whose seemingly bulletproof script just crashed.

The fact that we can invisibly or unexpectedly alter tid's is the result of a design decision. There were probably compelling reasons for that decision but it creates pitfalls. Rather than constantly alerting people to the ensuing dangers, the general consensus seems to be that we should assiduously paper them over. That we should make it easy for people to write buggy code and get away with it, and harder for them to find their errors and learn from them.

I don't think I've ever seen anyone on this list point out that tid's weren't set before use in a posted script unless that was the direct cause of some error the poster was seeing. If you neglect to "restore" tid's, though, you'll invariably get spanked by the tid's police. As a result, some people think it's OK to assume tid's will be set to "" or that everyone will always "restore" them. It's not OK. It can't be, given the design decision that was made when AS was specified.

A social convention to restore tid's is only as reliable as the individuals in the social group, and that's not reliable enough for coding. (California law says drivers must stop for pedestrians. LA has an average of four pedestrian deaths per week and one injury every two hours. One wonder's how many of those accidents are a result of the very law that was intended to prevent them: most drivers do stop and few yell or blow their horns at careless peds, since the law is on the peds' side, so it's easy for peds to form dangerous habits.)

I don't think that anyone here has suggested that this is not the case. Not even Bill with his rebelious TIDs scofflaw ways.

I hope I've rectified that oversight.

--
bill
_______________________________________________
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: TIDs info summary
      • From: Paul Skinner <email@hidden>
    • Re: TIDs info summary
      • From: Richard Morton <email@hidden>
References: 
 >TIDs info summary (From: Paul Skinner <email@hidden>)

  • Prev by Date: Re: Tid's 'n AS
  • Next by Date: TIDs default in AS is {""}
  • Previous by thread: Re: Finder selection in column view
  • Next by thread: Re: TIDs info summary
  • Index(es):
    • Date
    • Thread