Re: script object property contamination
Re: script object property contamination
- Subject: Re: script object property contamination
- From: has <email@hidden>
- Date: Wed, 20 Feb 2002 13:57:24 +0000
[apols for slow response - I was distracted for a few days]
The Mighty Scott Norton Was Finally Goaded Into Writing:
>
I've been quiet because I'm suspicious about the whole use of handlers as
>
dynamic, assignable values. It smells to me like a partially implemented
>
thing.
Could be... AS isn't exactly short of those.
>
Perhaps its better called an accidental feature, and may
>
accidentally disappear in the future.
Possible, though I'd think it unlikely it'd actually disappear. Handlers
are objects just like everything else in AS and I can't think of any reason
why this might be changed (which'd be like breaking the metaphor in order
to "save it").
I agree this scoping problem probably won't be fixed - the AS team has
plenty more pressing things to be doing than fixing some esoteric oversight
that would never have turned up if it weren't for a few lunatics doing
unexpected things with the language (not that that's a bad thing in
itself).
It's just unfortunate that AS has these sorts of caveats and gotchas that
make it hard to predict behaviour for some object based on what you already
know about the behaviour of other objects. Without predictable behaviour
you can't trust to intuition, meaning you have to learn everything
from-the-book instead (lots more work). Frustrating, but it's out of our
hands so what can we do?
>
But more importantly, its just as effective to use a script object, and that
>
approach is documented by Apple, with the scoping rules described in detail.
True, though if there's a simpler, straighter path available then using it
instead isn't a Bad Thing per-se. Using a simpler, straighter path that's
*undocumented* is a riskier undertaking; you're right there.
I think the two advantages of manipulating handlers like this are that it
makes for less verbose code (e.g. strftimeLib uses this approach and is
~100 lines shorter and slightly more readable as a result), and that it
gives you a degree of flexibility in how objects can act on other objects
that you'd otherwise only get through using OO design (which is a bit of a
big jump for procedural folks to make).
The disadvantage is (as you state) that it's an undocumented feature -
meaning that its "trustworthiness" isn't so good. Thanks for this note of
caution.
Mmmmm... now, I wonder if the same Man-Trap might work on Chris Nebel as well:
"I say, Chris Nebel is keeping awfully quiet on this thread; I wonder if
there isn't some vital insider wisdom that he might also impart upon this
subject...?" ;)
Regards,
has
_______________________________________________
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.