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

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


  • Subject: OO Programming (kinda like BDSM, but more painful and less fun...)
  • From: has <email@hidden>
  • Date: Sun, 30 Dec 2001 15:49:45 +0000

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.

--

Incidentally, it gets even more fun when z is loaded from an external
script. To then get it to find y requires even more craziness:

======================================================================

script z
global x --(and now it needs a global declaration of x too!)
x's y's foo()
end script

======================================================================

Ahhhh!

<sigh> Why does OOP always make me feel like Alice? (Fortunately, I do have
a bottle labelled "Drink Me" for occasions like these. Well, actually it
says "45.8% vol", but that's close enough for me...:)

Ta,

has


  • Follow-Ups:
    • Re: OO Programming (kinda like BDSM, but more painful and less fun...)
      • From: garbanzito <email@hidden>
    • Re: OO Programming (kinda like BDSM, but more painful and less fun...)
      • From: Paul Berkowitz <email@hidden>
  • Prev by Date: Re: Sort of [OT]: Raw Codes Database
  • Next by Date: Re: Source Text of Script Objects
  • Previous by thread: Bug in Display Dialog
  • Next by thread: Re: OO Programming (kinda like BDSM, but more painful and less fun...)
  • Index(es):
    • Date
    • Thread