• 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: how?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how?


  • Subject: Re: how?
  • From: Paul Scott <email@hidden>
  • Date: Wed, 13 Jan 2010 22:50:09 -0800

On Jan 13, 2010, at 9:52 PM, Paul Berkowitz wrote:
> ... the ingenious source of that technique was Ray Robertson - all credit due to him.

No way.

The technique is probably as old as structured programming itself, and has been reinvented time and again in many programming languages. I developed the technique on my own writing C code (shortly after God invented dirt), to keep my code simple, easy to read, and maintainable. Often I've wished end_do was part of the C language, but since it's not I always have a header file with

#ifndef end_do
#define end_do while (0)
#endif

So, I can write code like

do {
    ...
    if ...
    	break;
    ....
} end_do;

of course, when I started writing AppleScript, out of necessity this became

repeat -- once
    ....
    if ...
       exit repeat
    end if
    ...
    exit repeat
end_repeat

Variations on the theme are possible, but I've settled on this particular approach. I wish "repeat once" was actually part of the language, because if you accidentally leave out the final exit, all hell breaks loose; and the alternative "repeat 1 times" is ugly as sin.

There are, of course, other less pure ways to make such code work, but any programmer worth his salt will naturally develop the technique independently, unless first shown it by someone more experienced.

Any attempt to name "programmer-zero" is an absurd endeavor, and gives undue praise to one person.

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

  • Follow-Ups:
    • Re: how?
      • From: Chris Page <email@hidden>
    • Re: how?
      • From: Chris Page <email@hidden>
    • Re: how?
      • From: Paul Berkowitz <email@hidden>
    • Re: how?
      • From: Shane Stanley <email@hidden>
References: 
 >Re: how? (From: Paul Berkowitz <email@hidden>)

  • Prev by Date: Re: how?
  • Next by Date: Re: how?
  • Previous by thread: Re: how?
  • Next by thread: Re: how?
  • Index(es):
    • Date
    • Thread