• 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: Non-executed repeat loop robs variable of value/definition
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Non-executed repeat loop robs variable of value/definition


  • Subject: Re: Non-executed repeat loop robs variable of value/definition
  • From: kai <email@hidden>
  • Date: Sun, 28 Aug 2005 18:38:38 +0100


On 28 Aug 2005, at 18:04, Matt Neuburg wrote:

On Sun, 28 Aug 2005 16:21:56 +0100, kai <email@hidden> said:

set n to 1
if false then repeat with n from 1 to 2
end repeat
n

This should not even compile. You have an "end repeat" without a matching
"repeat". However, let's ignore that! :)

The "repeat" is in the preceding line, Matt. If this kind of syntax is wrong, I've been getting away with it since... ooh, Mac OS 8.x, I think. ;-)


The problem is that you are redefining a global as a local. This is not
illegal but it cuts off your access to the global (see my book for copious
and gory details). The repeat is not executed but it is still parsed by the
compiler and still performs the local declaration implicitly. To solve the
problem, be good and Declare Your Variables!

I appreciate the point you're making.

What I find interesting is what happens if you change false to true, i.e. it
works fine. I guess if the repeat block actually executes, then by that
time, a global n exists and is in scope and the repeat block uses it
instead. So I'd say what you've found is a bug, because the two really
should behave the same way. But then, this whole thing about implicit
declaration of variables is one massive mistake in my opinion anyway: there
was never a hope in Hades that every case would get covered coherently, and
you've neatly poked a hole in it. m.

Much obliged, Matt. I'll file a bug to see if the hole can be repaired at some stage...


Thanks again,

---
kai


_______________________________________________ Do not post admin requests to the list. They will be ignored. Applescript-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Re: Non-executed repeat loop robs variable of value/definition (From: Matt Neuburg <email@hidden>)

  • Prev by Date: Basic Eudora Question: Make New Mailbox
  • Next by Date: Re: Non-executed repeat loop robs variable of value/definition
  • Previous by thread: Re: Non-executed repeat loop robs variable of value/definition
  • Next by thread: Re: Non-executed repeat loop robs variable of value/definition
  • Index(es):
    • Date
    • Thread