• 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: Handlers and Tell Blocks
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Handlers and Tell Blocks


  • Subject: Re: Handlers and Tell Blocks
  • From: Paul Berkowitz <email@hidden>
  • Date: Wed, 28 Aug 2002 16:04:57 -0700

On 8/28/02 2:40 PM, "has" <email@hidden> wrote:

>> The whole discussion, which I know was very confusing, was prompted by a
>> study of the Mail Scripts which Apple kindly provided. [...] Like this:
>>
>>
>> tell application "Microsoft Entourage"
>> tell eachContact
>> theScript's setFirstName(newEntry, first name)
>> theScript's setLastName(newEntry, last name)
>> theScript's setTitle(newEntry, title)
>
> I find this just a little too clever for its own legibility, what with the
> way the tell blocks and object references have all been nested. I would
> tend to lay it out as follows - while it's a bit longer, it's also very
> straightforward to read:
>
> tell application "Microsoft Entourage"
> tell eachContact
> set firstName to first name
> set lastName to last name
> set theTitle to title
> end tell
> end tell
> --
> tell theScript
> setFirstName(newEntry, firstName)
> setLastName(newEntry, lastName)
> setTitle(newEntry, theTitle)
> end tell

Well, yes. That's the way I've always done things before. It does feel
cleaner, but seemed to be OK the other too. Maybe there's a school of
thought that believes in not using too many variables (easier on the
memory?). Perhaps the first method derives from that. That's one of the
things I was wondering.
>
> Now, whether there's any practical difference other than improved
> readability, such as the first version being faster, I don't know (and even
> if it was a bit faster, you really have to consider the difference in terms
> of the overall running time before deciding if it's a. significant, and b.
> worth compromising your code's clarity for). But it is very easy to get
> carried away in the first flush of OOD and deep-nest your tell blocks at
> every opportunity imaginable. I certainly did - but those initial bouts of
> extreme cleverness pretty much worn off again once I found the plainer,
> simpler (dare I say "duller"?) style made for easier and more durable code
> in the long run.
>
> I think as far as the to-nest-or-not-to-nest thing goes, follow your gut
> and use whatever looks clearest and simplest and least likely to hurt your
> brain. This is probably still not the right answer to your intended
> question, mind you, but I hope it's at least a little less wide of the mark
> than the last one...;)

Yes, thanks.

--
Paul Berkowitz
_______________________________________________
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.

References: 
 >Re: Handlers and Tell Blocks (From: has <email@hidden>)

  • Prev by Date: Re: AppleScript Try
  • Next by Date: How can you detect that application is curently running?
  • Previous by thread: Re: Handlers and Tell Blocks
  • Next by thread: Re: Handlers and Tell Blocks
  • Index(es):
    • Date
    • Thread