[jawsscripts] Re: Resizing arrays

  • From: Doug Lee <doug.lee@xxxxxxxxxxxxxxxx>
  • To: jawsscripts@xxxxxxxxxxxxx
  • Date: Thu, 5 Jan 2012 15:50:53 -0500

An interesting result, indeed. I drew my initial assumption in favor
of reference copy rather than deep copy from the following paragraph
from an FS document, though this documentation may be old and, off the
top of my head, I don't remember where the current version would be
found:

"
Assignment expressions for elements of an array work as expected with []
being used to enclose the index expressions identifying the item to be
assigned. Arrays are always passed to functions by reference, and
assigning one array to another will result in two variables referring to
the same array. This is to avoid the very expensive process of copying
arrays
"

On Thu, Jan 05, 2012 at 05:44:22PM -0300, Andrew Hart wrote:
On 5/01/2012 4:55 PM, Doug Lee wrote:
> A couple clarifications:
> 
> First, to me at least, a "deep copy" is a full duplication of
> something with all subparts. My understanding of "s2 = s1" where they
> are arrays is that, in JAWS, only the pointer is copied. It still
> works for your usage though, so this is mostly just behind-the-scenes
> stuff for this case.

No.  Assigning one array to another is truly a deep copy in JAWS script.
 I have tested this by making a copy and overwriting the original.
Afterwards, I still had access to the original array in the form of my
copy,as well as the new array I had created.

Please feel free to test it for yourself.  It would be great to have
Coroboration from others.

> Second though, your code assumes array sizes, and most of my cases
> don't have a clue in advance what size to use. As an example, consider
> code that creates a structure of information for each entry in a chat
> window. If the process of counting entries is as expensive as that for
> actually retrieving them, there's no reasonable way to know in advance
> how big to make the array. A collection becomes more efficient in this
> case, because it is dynamic while still being amenable to random
> access.

No argument here Doug.  Collections have their advantages.  My comment
was in response to Travis's requirements.

Cheers,
Andrew.


__________???

View the list's information and change your settings at 
//www.freelists.org/list/jawsscripts

-- 
Doug Lee, Senior Accessibility Programmer
SSB BART Group - Accessibility-on-Demand
mailto:doug.lee@xxxxxxxxxxxxxxxx  http://www.ssbbartgroup.com
"While they were saying among themselves it cannot be done,
it was done." --Helen Keller
__________�

View the list's information and change your settings at 
//www.freelists.org/list/jawsscripts

Other related posts: