passing parameters in a send call.
Graham Samuel
livfoss at mac.com
Mon May 22 11:00:31 EDT 2006
On Sun, 21 May 2006 15:28:28 -0600, Dar Scott <dsc at swcp.com> wrote
> On May 21, 2006, at 3:01 PM, Sarah Reichelt wrote:
>
>
>> I always use something like:
>> send "myAdd " & pArrayA to stack "someStack"
>>
>> so that the variable is evaluated before the send.
>>
>
> Hi, Sarah!
>
> I'll pick on two aspects of that.
>
>
> First of all, I haven't been convinced that there are any merits to
> this:
>
> send "myCmd " & x & comma & y to ...
>
> Over this:
>
> send "myCmd x, y" to ...
>
> And it has some potential problems, such as when x contains a comma.
> (Also, the latter lends itself to some future (I hope) compiler
> optimization that compiles code that does not require runtime
> compiling.)
>
>
> Second, in this particular case where pArrayA is an array, the
> expression '"myAdd " & pArrayA' will resolve to "myAdd ". The array
> value looks empty to '&'.
Isn't it true that
send "myCmd x,y" to...
just sends that exact string (minus the quotes) to the target: if
so, the target environment can only resolve x and y if it's in the
same name space as the script that did the sending (I mean if it is
able to evaluate x and y), which is in general not true (after all,
the point of handler parameters is to pass information from one
context to another). So if I'm right
send "myCmd"& x &","& y to...
first evaluates x and y in the context of the sender (which is what
Sarah said) and therefore achieves the expected result, whereas the
other method doesn't. Arrays being a special case may not work
anyway, but I'm trying to make a more general point.
I hope what I've just written makes sense.
Graham
----------------------------------------
Graham Samuel / The Living Fossil Co. / UK and France
More information about the use-livecode
mailing list