> -----Original Message-----
> From: TSO REXX Discussion List [mailto:
TSO-...@VM.MARIST.EDU] On Behalf
> Of Lizette Koehler
> Subject: Re: How do I explain REXX Storage Usage
>
> So I wanted a little clearer understanding at this point as to storage
> allocation during REXX execution (I do not have the compiler so always
> interpreted).
>
> So if I have a simple REXX
>
> A = myvar
> B = myvar
>
> Both of those take an individual storage location. Or does REXX point A
and B
> to the same storage location?
Can A and B point to the same location? Do interpreters do optimizations of
this sort? Would
A = B
cause A and B to point to the same location?
If you run this under TSO TEST or XDC, you should be able to determine where
A and B point.
How about
A = myvar
myvar = myvar+1
B = myvar
After the first assignment, does A point to the same place myvar points or
to a new area holding a copy of myvar's data? After the second, does myvar
point to a new area? If so and A pointed to the old area, REXX has to know
not to release that memory because A is still using it. Did the value in A
change? Is A equal to B?
> But if I now do
>
> Do I = 10
> Parse Var stem.i myvar .
> A = myvar
> B.i = myvar
> End
>
> I think on each iteration it is a new address for the storage location of
the
> vars A & B.i .
All REXX variables are stored as strings. Even the simple sequence
A = myvar
A = myvar
requires either new memory OR a determination that the new value can fit in
the space already allocated. Does the routine that performs assignments try
to determine if space can be reused? If new space is allocated, is the old
space released immediately or does some threshold trigger a garbage
collection algorithm?
If you test, does the address pointed to be A change after the second
assignment?
>
> Do I have that correct.
>
> If so, then Dropping the stem would free up that storage and reduce what
storage
> is allocated for my variables.
Is the memory for dropped variables freed immediately or does garbage
collection occur later?
> So instead of having 10 storage locations for A and B.i - I would have
one for
> A and 10 for B.i ????? So I would need to drop B.i before finishing the
loop?
If there is a real reason for using B.i instead of B, then you probably
don't want to drop any B.i until well after the loop is finished. If you
drop B.i before the loop finishes, you cannot refer to B.(i-1) in the next
iteration so having a stem element seems a waste.