• 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 to do a goto with Applescript?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to do a goto with Applescript?


  • Subject: Re: How to do a goto with Applescript?
  • From: Luther Fuller <email@hidden>
  • Date: Mon, 10 Jan 2011 11:13:16 -0600

On Jan 10, 2011, at 10:50 AM, Mark J. Reed wrote:

On Mon, Jan 3, 2011 at 11:27 AM, Skeeve <email@hidden> wrote:
Am 03.01.11 15:45, schrieb David Crowe:

There's always a better way to write the code than use a goto.
Some well known scientists and programmers disagree like  Linus Torvalds, Steve McConnell or Donald Knuth http://pplab.snu.ac.kr/courses/adv_pl05/papers/p261-knuth.pdf

Goto is not inherently evil, and Dijkstra may have overstated his case, but the point stands.  In 1968 people were writing code to maximize efficient use of space.  Things got moved around, and you wound up with control flow that was nothing like the order of the source code text.  That's what they mean by spaghetti code.

I recall doing a bit of Basic programming many, many years ago. 'goto 456' lacks description. On the other hand, 'do mountSparsebundleDisk(...)' is informative. And it's easy to return to the calling point.

The occasional goto can be quite liberating, saving you from having to exit out of deeply nested loops or conditionals or whatnot.

The only 'goto' that I found liberating in AppleScript is 'error number -128'.

Pure structured-programming advocates look down not only on goto, but also on break ("exit loop", "last", whatever your language calls it), insisting that loops should have only one entry and exit.  In my experience that often means most of the code is deeply nested inside some conditionals and indented halfway across the page. So a purist I ain't. :)

Most of the deep nesting in an AppleScript repeat loop could be avoided if there were an 'next repeat' command in AppleScript.

 _______________________________________________
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 to do a goto with Applescript?
      • From: Alex Zavatone <email@hidden>
References: 
 >Re: How to do a goto with Applescript? (From: Skeeve <email@hidden>)
 >Re: How to do a goto with Applescript? (From: "Mark J. Reed" <email@hidden>)

  • Prev by Date: Re: How to do a goto with Applescript?
  • Next by Date: Re: How to do a goto with Applescript?
  • Previous by thread: Re: How to do a goto with Applescript?
  • Next by thread: Re: How to do a goto with Applescript?
  • Index(es):
    • Date
    • Thread