Opened 12 years ago
Closed 12 years ago
#2679 closed Feature Request (Rejected)
Undocumented behaviour of arrays
| Reported by: | rindeal | Owned by: | |
|---|---|---|---|
| Milestone: | Component: | Documentation | |
| Version: | Severity: | None | |
| Keywords: | Cc: |
Description
reffering to a part of array that is being declared
$avArray[2]=["foo",$avArray[0]]
Attachments (0)
Change History (6)
comment:1 by , 12 years ago
| Version: | 3.3.10.0 |
|---|
comment:2 by , 12 years ago
Sidenote: works as expected only on when referring to elements whose assignment have already been parsed, i.e. doesn't work as expected on elements placed after the reference.
#include <array.au3> Local $avArray1 = ["foo", $avArray1[0], "bar"] _ArrayDisplay($avArray1, "As expected") Local $avArray2 = ["foo", $avArray2[2], "bar"] _ArrayDisplay($avArray2, "Pitfall")
comment:3 by , 12 years ago
sidenote:
and you have to use a directive #forcedef to prevent errors displayed by AU3Check
#include <array.au3> #forcedef $avArray1 Local $avArray1 = ["foo", $avArray1[0], "bar"] _ArrayDisplay($avArray1, "As expected") #forcedef $avArray2 Local $avArray2 = ["foo", $avArray2[2], "bar"] _ArrayDisplay($avArray2, "Pitfall")
comment:4 by , 12 years ago
Please provide an example of where this declaration "quirk" would be useful. At present I am more inclined to get it removed than document it and confuse everyone.
M23
comment:5 by , 12 years ago
I partly agree, yet it can be handy in some cases to avoid duplication of literals but I don't know whether it's worth documenting.
#include <array.au3> ; Array of URLs: col0=site name, col1=from extranet, col2=from intranet, col3=login required, col4=user group #forcedef $aURLs Local $aURLs[4][5] = [ _ ["site AAA", "first very long URL for extranet access", $aURLs[0][1], $aURLs[0][1] <> $aURLs[0][2], $aURLs[0][3] ? "restricted" : "all"], _ ["site BBB", "second very long URL for extranet access", "exceptional actual intranet access", $aURLs[1][1] <> $aURLs[1][2], "webadmins"], _ ["site CCC", "third very long URL for extranet access", $aURLs[2][1], $aURLs[2][1] <> $aURLs[2][2], $aURLs[2][3] ? "restricted" : "all"], _ ["site DDD", "last very long URL for extranet access", $aURLs[3][1], $aURLs[3][1] <> $aURLs[3][2], $aURLs[3][3] ? "restricted" : "all"] _ ] _ArrayDisplay($aURLs, "Devil's advocate example")
comment:6 by , 12 years ago
| Resolution: | → Rejected |
|---|---|
| Status: | new → closed |
It's not worth documenting, as if it were Jon would have does so when the array datatype was included as part of AutoIt. Don't get me wrong, I have used it too as a neat workaround but other languages such as C# don't allow this sort of behaviour.

Automatic ticket cleanup.