﻿id	summary	reporter	owner	description	type	status	milestone	component	version	severity	resolution	keywords	cc
2029	Array and variable handling / suggestion	Shaggi		"1. Accessing temporary arrays
This could be a cool feature, and in many cases reduce code in larger expressions. Also, it will solve the problems explained later down. Example:

{{{
Func n()
	Local $Array[2] = [1,2]
	Return $Array
EndFunc

MsgBox(0,"""",n()[1])
}}}

2. Ability to have 2 variables reference the same content.
This is already working through ByRef parameter passing, however when you return a referenced parameter it creates a copy. Example:

{{{
Global $Array[2] = [""foo"",""foo""]
$Array2 = n($Array)
$Array2[1] = ""bar""
ConsoleWrite($Array[0] & @CRLF & $Array[1])

Func n(ByRef $Array)
	Return $Array
EndFunc
}}}
This is the same with normal variables.
3. Nested arrays / Arrays in arrays and linked lists
Since arrays can store other arrays, why cant you access them without getting bounds errors? This seems more like a faulty parsing case than a limitation within autoit:

{{{
#include <Array.au3>
Dim $a[2]
Dim $b[2]

$b[0]=""foo""
$b[1]=""foo""
$a[0] = ""bar""
$a[1] = $b

_ArrayDisplay($a)
_ArrayDisplay($a[1])

ConsoleWrite($A[0])
ConsoleWrite($A[1][0]) ;Error
}}}
It seems that when arrays are assigned to elements of others, they are stored as temporary variables - maybe this is related to #1? If this could be fixed, it would allow many things - like a more structured design like linked lists or better ability to write something object oriented.
As it stands now, the only way to modify the contents of an nested array (without creating a copy of the index, modifying and assigning back) is through byref parameter functions, so you can access the element. Example:
{{{
#include <Array.au3>
Dim $a[2]
Dim $b[2]

$b[0]=""foo""
$b[1]=""foo""

$a[0] = ""bar""
$a[1] = $b

_ArrayDisplay($a)
_ArrayDisplay($a[1])
Change($A[1])
_ArrayDisplay($a[1])

Func Change(Byref $A)
	$A[0] = ""changed""
EndFunc
}}}
It is possible to do it this way, however when you have a nested array (c) inside a nested array (b) in a array (a), it's near impossible to change contents of c without creating a new array - because as #2 states, a ByRef parameter returned is a new copy. And since you can only access nested arrays through ByRef parameters, you actually have to create a recursive byref function, that ""dereferences"" the array each time. This is a costly process, and pretty stupid. Example:

{{{
Func _C_NestChangeVal(ByRef $Obj, $Val, $Ref1 = -1, $Ref2 = -1,$Ref3 = -1)
	Switch @NumParams
		Case 5
			_C_NestChangeVal($Obj[$Ref3],$Val,$Ref1,$Ref2)
		Case 4
			_C_NestChangeVal($Obj[$Ref2],$Val,$Ref1)
		Case 3
			$Obj[$Ref1] = $Val
	EndSwitch
EndFunc
}}}
I hope this will be implemented, and since (i think) AutoIt supports it all, it shouldn't be that hard to do."	Feature Request	closed		AutoIt		None	Rejected	Array Variable list nested	
