WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: kdmoyers on November 06, 2025, 05:22:55 AM

Title: array assignment
Post by: kdmoyers on November 06, 2025, 05:22:55 AM
Just checking some things about arrays...

aaa = arrdimension(10,10)
bbb = aaa

In this example, bbb is a pointer to the aaa array, right? it's really the same array storage, just with an alternate variable name.

whereas

ccc = arrayslice(aaa,0,-1,0,-1)
Here ccc becomes a distinct copy of aaa, and can be independently modified, correct?

Title: Re: array assignment
Post by: kdmoyers on November 06, 2025, 05:24:23 AM
those colors came out freaky, here that is again in plain text:

Just checking some things about arrays...

aaa = arrdimension(10,10)
bbb = aaa

In this example, bbb is a pointer to the aaa array, right? it's really the same array storage, just with an alternate variable name.

whereas

ccc = arrayslice(aaa,0,-1,0,-1)

Here ccc becomes a distinct copy of aaa, and can be independently modified, correct?
Title: Re: array assignment
Post by: td on November 06, 2025, 09:35:36 AM
You are correct. Arrays and COM/.Net objects are the only WIL variables that are not deep copied on assignment. WIL uses reference counting for arrays and objects*. The ArraySlice function creates a new array, but uses WIL assignment rules for each element of the new array copied from the old array.

* Object assignment gets a little more complicated. In many cases, WIL allocates new memory to hold the object, but the underlying system object is reference counted.

I know. The above is about as clear as the coffee I am drinking as I type this.