• 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: handler failure
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: handler failure


  • Subject: Re: handler failure
  • From: Paul Skinner <email@hidden>
  • Date: Wed, 13 Nov 2002 11:40:35 -0500

On Wednesday, November 13, 2002, at 10:31 AM, Paul Skinner wrote:

On Wednesday, November 13, 2002, at 08:35 AM, has wrote:

Chris Espinosa wrote:

A handler is essentially a property in your script, and you can set it
to any value, including that of another function.

Unfortunately, this [undocumented] behaviour has always been broken:

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

script a
property _val : 1

on foo()
return _val
end foo
end script

script b
property bar : missing value
end script

a's foo()
--> 1

set b's bar to a's foo
b's bar
--> <<handler foo>> --!!!!!


This is correct. You assigned the contents of a's foo (which is the handler foo) to b's bar. Now b's bar contains the handler foo.
It looks to me like you meant to ...

set b's bar to a's foo()
-->1
b's bar
-->1

But I won't assume that. Nope.

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

When the handler object moves to a new context, it forgets its original
context (bad) and attempts to use the new one instead (worse). Mix in some
static bindings for laffs, and you can get some fantastically
incomprehensible results (...).

Context, hmm... maybe you wanted to preserve the context that the handler was in. You just captured the handler.
Maybe you wanted to...

set bar to a
bar's foo()
-->1

I certainly don't think that it should be expected that a handler plucked from it's environment should 'remember' how things used to be 'back on the farm script' so to speak. Think of the implications of objects carrying around all that baggage. think what would happen if you then make another iteration.
This might be a good time to point out that you might want to copy the object to the variable rather than set the variable to the object.

--
Paul Skinner

The results are what I expected. And if they change I'll have to rewrite some scripts. Just exactly what did you think the contents of b's bar should be?

Still Chris... now that you've opened Pandora's Box for all to see, any
chance this amnesia problem might be fixed in a future release?

has
--
Paul Skinner
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: handler failure
      • From: email@hidden (Michael Sullivan)
References: 
 >Re: handler failure (From: Paul Skinner <email@hidden>)

  • Prev by Date: Re: handler failure
  • Next by Date: Re: Problem with modification date of file...
  • Previous by thread: Re: handler failure
  • Next by thread: Re: handler failure
  • Index(es):
    • Date
    • Thread