• 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
Tid's 'n AS
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Tid's 'n AS


  • Subject: Tid's 'n AS
  • From: bill fancher <email@hidden>
  • Date: Tue, 05 Nov 2002 13:13:20 -0800

Nice day for a flame war (with apologies to the originator of of the phrase "tid's 'n AS", whose identity I've forgotten, but whose legacy lives on)...

A fundamental tenet of defensive programming can be boiled down to "Don't make unwarranted assumptions."

Here's a script:

set abc to text items of "abc"
set c to item 3 of abc

The above makes an unwarranted assumption about tid's. To code defensively, you'd write:

set text item delimiters to ""
set abc to text items of "abc"
set c to item 3 of abc

That will NEVER error (assuming AS itself isn't broken.) Perhaps good programming rules say "every handler will restore tid's to the value they had on entering the handler", but people don't always follow rules, and the code they write doesn't either. Such a "good programming rule" has no empirical basis. It's a PREscription, not a DEscription. In the real world, people screw up. You can assume they won't and get burned from time to time, or program defensively.

There IS no default value for tid's. That would be the case if you could say:

set abc to text items of "abc" with text item delimiters x

and if the statement

set abc to text items of "abc"

were equivalent to

set abc to text items of "abc" with text item delimiters ""

There's an INITIAL value given to tid's by AS. There's a CURRENT value for tid's. But there's no default. Assuming that the current value is the initial value (or anything else) or that there's a default is where the problem lies.

I NEVER "restore" tid's. I laugh at the tid's police. I'm a terrible person, I WON"T change my despicable ways, and my code is coming to get you. Be careful out there.

--
bill

'Truth unfolds in time through a communal process.' - CQ
_______________________________________________
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: Tid's 'n AS
      • From: Michael Terry <email@hidden>
    • Re: Tid's 'n AS
      • From: email@hidden (Michael Sullivan)
    • Re: Tid's 'n AS
      • From: Bill Briggs <email@hidden>
  • Prev by Date: Re: Removing characters from a string
  • Next by Date: Re: Unmount a partitioned volume
  • Previous by thread: [PR] 24U Appearance OSAX 2.1 for Mac OS X available!
  • Next by thread: Re: Tid's 'n AS
  • Index(es):
    • Date
    • Thread