Modify

Opened 11 years ago

Closed 11 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 Changed 11 years ago by TicketCleanup

  • Version 3.3.10.0 deleted

Automatic ticket cleanup.

comment:2 Changed 11 years ago by jchd18

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 Changed 11 years ago by mlipok

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 Changed 11 years ago by Melba23

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 Changed 11 years ago by jchd18

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 Changed 11 years ago by guinness

  • Resolution set to Rejected
  • Status changed from new to 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.

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The ticket will remain with no owner.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.