• 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: Thu, 14 Jan 2010 17:23:38 -0800

It definitely has more power than other techniques constrained by the limitations of whatever target language.

Are you suggesting this syntax might find it's way into AppleScript?

If so, consider these changes:

-- start example, where [ ] surrounds optional syntax

[set var to ] block label
    ...
    if someCondition then
        exit [label] [ with [optional value[s] of any type] ]
    end
    ...
end block

[set var to result]

-- end example

Although using a label accomplishes much the same thing as a named exit function, I prefer the label/exit/with syntax better because it's more consistent with existing AppleScript. It is allows for better reading, self documenting code.

block theOuterLoop
    block theInnerLoop
        ....
        exit theOuterLoop
    end block
end block

reads much better than "block exitTheOuterLoop" ...

Professionally, I write code in High Level Assembler (that's the name of the assembler, not a personal gloat) using structured macros that support labelled blocks to allow exiting an outer block from an inner one. It's quite powerful, and I make use of it where appropriate.

Paul
On Jan 14, 2010, at 4:36 PM, Chris Page wrote:

> On Jan 13, 2010, at 10:50 PM, Paul Scott wrote:
>
>> 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.
>
> The real way to address this (in any programming language design) is to provide explicit support for exiting a local scope. For example, in Dylan, you can write:
>
>  block (exit-this-block)
>    ...
>    if some-condition then
>      exit-this-block()
>    end
>    ...
>  end

<snip>

> It might look like this in AppleScript:
>
>  block exitThisBlock
>    ...
>    if someCondition then
>      exitThisBlock(42)
>    end
>    ...
>  end
>  log the result --> “42"

 _______________________________________________
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

References: 
 >Re: how? (From: Paul Berkowitz <email@hidden>)
 >Re: how? (From: Paul Scott <email@hidden>)
 >Re: how? (From: Chris Page <email@hidden>)

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