assign by reference (arrays)?

Rob Cozens rcozens at
Fri Mar 22 13:26:01 EST 2002

>I think I understand what Ben is after -- to [vaguely] borrow terminology
>from other languages, what it appears he wants to do is:
>    case "use"
>      put ADDRESS_OF(aUseInfo) into aInfoPointer
>    ...
>    end switch
>    add 1 to TARGET_OF(aInfoPointer)[rID]
>[note: I'm COMPLETELY new to this "language" -- while I have a number of
>other languages under my belt, I'm not entirely sure I want to tackle one
>where the global variable "it" changes context from line to line... ;) ]
>Does this "language" support pointer variables [and all the nastiness
>associated with them] or is this a dead avenue?

Hi Tom,

No, neither Transcript nor any other Xtalk dialect I'm aware of 
includes syntax for pointers or handles.  Some of us would like to 
see it, at least so far as is necessary to support direct system 
calls from Transcript.

>A bit of a SWAG here, but from another post, it appears that by using the
>"do" command it's possible to "dereference" a variable so long as you know
>it's name.  If I picked up on the proper usage, it should be something like

When I first started with HyperTalk I was struck by the techniques 
used by the folks at Apple who scripted the suite of HyperCard stacks 
to reference objects and variables "on the fly."  I thought, why had 
I never done this in FORTRAN, PL/1, Pascal, or C?  Then I realized 
there was no way to do this in any of those languages because in most 
the reference was resolved at compile time and even in UCSD Pascal 
the interpreter didn't support "do".

As an aside, not only can you resolve objects & variables at runtime; 
you also have the capability of writing self-modifying code.  Think 
about the potential of that feature.

>  > Try this, Ben,
>[paraphrased -- please let me know if I'm way off base here...]
>         [...]
>However it appears even you have doubts about this as you brought up a few
>cases in another post where it sounds like this is a less-than-optimal
>solution [not even taking into consideration the fact that dereferencing a
>pointer takes the same number of cycles & memory space regardless of the
>array being 10 bytes or 10 megabytes in size, OTOH, "copies" of entire

At the time I wrote this I had no experience working with arrays in 
Xtalk, as they are not supported in HyperTalk.  Since then I scripted 
the following test which convinces me the script should work:

on testArray
   put "Hello" into myArray[20]
   put "cruel" into myArray[30]
   put "world" into myArray[25]
   put "anyString" into myString
   put myArray into myString
   put "someThingElse" into myArray
   put myString into myArray
   put myArray[20]&&myArray[30]&&myArray[25]&"!"
end testArray

So in the end it seems to boil down to whether the overhead of 
calling a separate handler every iteration of the loop is more or 
less than the overhead of copying the array each time.

Yes, I see how using a pointer or handle reference "in line" would 
give you the best of both worlds, Ben.  If you really want this kind 
of syntax, I suggest you bring it up on the Xtalk List.

Rob Cozens
CCW, Serendipity Software Company

"And I, which was two fooles, do so grow three;
Who are a little wise, the best fooles bee."

from "The Triple Foole" by John Donne (1572-1631)

More information about the use-livecode mailing list