• 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: OO Programming (kinda like BDSM, but more painful and less fun...)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: OO Programming (kinda like BDSM, but more painful and less fun...)


  • Subject: Re: OO Programming (kinda like BDSM, but more painful and less fun...)
  • From: Paul Berkowitz <email@hidden>
  • Date: Sun, 30 Dec 2001 10:58:39 -0800

On 12/30/01 7:49 AM, "has" <email@hidden> wrote:

> OK, this problem's for object-oriented heads only; I won't be held
> responsible if anyone else hurts themselves on it.
>
> I imagine this is a scope issue, but don't understand why.
>
> This works:
>
> ======================================================================
>
> script x
> script y
> on foo()
> beep 2
> end foo
> end script
>
> script z --(z is inside x)
> y's foo()
> end script
> end script
>
> tell x's z to run
>
> ======================================================================
>
>
> This doesn't:
>
> ======================================================================
>
> script x
> script y
> on foo()
> beep 2
> end foo
> end script
> property z : {}
> end script
>
> script z --(z is outside x)
> y's foo()
> end script
>
> set x's z to z --(chuck z into x at runtime)
>
> tell x's z to run
>
> ======================================================================
>
>
> But with a slight tweak it does:
>
> ======================================================================
>
> script x
> script y
> on foo()
> beep 2
> end foo
> end script
> property z : {}
> end script
>
> script z
> x's y's foo() --(note change from previous example)
> end script
>
> set x's z to z
>
> tell x's z to run
>
> ======================================================================
>
>
> Now, the first two examples would appear to be equivalent, but only the
> first one works (the other couldn't find y to save itself). I'm curious as
> to exactly what is going on here, and why that should affect things so.


They don't seem equivalent to me.

In your second example, you may be setting x's z to z , but z's y is
undefined. AppleScript will compile it, but you haven't defined y inside the
external z. So even when you tell x's z to run, the y of x's z is _not_ the
same y as x defines as a handler. They don't know about each other at all.

Whereas in the third eaxmple you specifically call x's y inside z, so when
you make set x's z to z, the y it's calling is its own y.

Well, it's clear to me anyway...

--
Paul Berkowitz


References: 
 >OO Programming (kinda like BDSM, but more painful and less fun...) (From: has <email@hidden>)

  • Prev by Date: Re: Source Text of Script Objects
  • Next by Date: Re: Source Text of Script Objects
  • Previous by thread: OO Programming (kinda like BDSM, but more painful and less fun...)
  • Next by thread: Re: OO Programming (kinda like BDSM, but more painful and less fun...)
  • Index(es):
    • Date
    • Thread