[jawsscripts] Re: Resizing arrays

  • From: Andrew Hart <ahart@xxxxxxxxxxxxx>
  • To: jawsscripts@xxxxxxxxxxxxx
  • Date: Thu, 05 Jan 2012 18:06:03 -0300

Doug,

Most interesting.  But now you have me doubting myself and the test I did.

Let me know if you try it out for yourself and what result you get.  I
must confess, I was surprised too, for such would be more in line with
visual Basic and DotNet, from which JAWS Script has clearly taken some
inspiration in recent times.

Cheers,
Andrew.

On 5/01/2012 5:50 PM, Doug Lee wrote:
> 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
> 


__________�

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

Other related posts: