Re: Looks like a bummer
Re: Looks like a bummer
- Subject: Re: Looks like a bummer
- From: Chris Nebel <email@hidden>
- Date: Thu, 14 Dec 2000 12:10:23 -0800
- Organization: Apple Computer, Inc.
Richard 23 wrote:
>
Is it possible for a script applet to modify a record passed to it,
>
with the modification reflected in the caller?
No, because once you start talking to another application, you're using
AppleEvents, and AppleEvents pass all parameters by value. As you
noticed, this doesn't match what happens locally within a script, where
complex values (i.e. lists, records, and strings) are implicitly passed
by reference.
This is admittedly kind of lame, but it would be extremely awkward to
change. The reason AppleEvents do everything by value is that they were
designed to be able to go from machine to machine, which means you just
can't do a reference parameter. (On Mac OS X, it's hard to do a
reference parameter even when talking to another application on the same
machine, because they're in different address spaces.) You could fake
reference parameters using a copy-copy-back approach (i.e., A sends B a
value; B replies with an altered value that A replaces its original
with), but then why not just design your call a bit differently? The
other way to make things consistent would be to say that AppleScript
parameters are always by value, but then lots of scripts would break in
subtle ways, because people are relying on the by-reference nature.
I'm afraid you'll just have to find a different way to take over the
world...
--Chris Nebel
AppleScript Engineering