Modify

Opened 16 years ago

Closed 13 years ago

#1186 closed Feature Request (Rejected)

native support of array "slices" as Lvalue and Rvalue

Reported by: anonymous Owned by: Nutster
Milestone: Component: AutoIt
Version: Severity: None
Keywords: array Cc:

Description

Please enhance the current array datatype by array slices (i.e. "subarray" or "part of array") natively.

I know, this feature can be implemented by UDFs, too. Nevertheless I ask it as feature request due

  • UDFs need individual code for each supported dimension. They would become quite fat for supporting all possible 64 dimensions of arrays. (So today's UDFs will support 1D, fewer do 2D, and that's it).
  • native support is faster
  • syntax is common in other languages, therefore "expected" by the normal programmer (until he becomes an AutoIt maniac)

Example:
After DIMensioning an array $a[u][v] you can use the syntax $a for whole array (already available), $a[x][y] to address the content in cell x,y (already available), and (new) $a[x] for the sub-array $a[x][*] (1D array with subscript: [v])

; == 3D Array -> 2D- or 1D "slices" as RValue ==
Dim $a[4][3][2] = [[["000","001"], ["010","011"], ["020","021"]], _
                   [["100","101"], ["110","011"], ["120","121"]], _
                   [["200","201"], ["210","211"], ["220","221"]], _
                   [["300","301"], ["310","311"], ["320","321"]]]
Local $b
$b = $a ; already AVAILABLE: copy whole array
$b = $a[1] ; requested: extract array slice of $a and assign it to $b
           ; here: copy $a[1][*][*] as 2D array, this equates the statement
           ; Local $b[3][2] = [["100","101"],["110","011"],["120","121"]]
$b = $a[1][2] ; requested: extract array slice of $a and assign it to $b
           ; here: copy $a[1][2][*] as 1D array, this equates the statement
           ; Local  $b[2] = ["120","121"]
$b = $a[1][2][0] ; already AVAILABLE: copy content, here: $b = "120"


; == 3D Array -> 2D- or 1D "slices" as LValue ==
Dim $c[3][2] = [["aaa","AAA"], ["bbb","BBB"], ["ccc","CCC"]]
$a[1] = $c  ; replace addressed values of $a[1][x][y] by values of $c[x][y]
            ; NOTE: identical dimension (2D) and subscript ([3][2]) on both sides!
            ; NOTE: $a[0][][], $a[2][][] and $a[3][][] stay unmodified
$a[3][2] = ["xxx", "XXX"]
            ; replace addressed values of $a[3][2][*] by given values
            ; NOTE: identical dimension (1D) and subscript ([2]) on both sides!
$a[2][2][1] = "###" ; already AVAILABLE: change content of array element 

; now array $a has become:
;  [[["000","001"], ["010","011"],["020","021"]], _
;   [["aaa","AAA"], ["bbb","BBB"], ["ccc","CCC"]], _  ; <= $a[1] = $c
;   [["200","201"], ["210","211"], ["220","###"]], _  ; <= $a[2][2][1] = "###"
;   [["300","301"], ["310","311"], ["xxx","XXX"]]]    ; <= $a[3][2] = ["xxx", "XXX"]


Attachments (0)

Change History (3)

comment:1 by Valik, 16 years ago

I know you put slices in quotation marks but this isn't really slicing. Slicing is something else entirely.

Anyway, I do agree with the feature. The syntax is intuitive to anybody who would even use it in the first place.

comment:2 by Nutster, 16 years ago

Owner: set to Nutster
Status: newaccepted

I can see how to do the RValue version of this feature, but because of the way that arrays are stored internally, I do not see the LValue modifications as being practical. I mean, I can clearly see the use for the LValue version, but its would be too much of a pain to implement.

Accepting RValue version of dimensional slicing.

comment:3 by Jon, 13 years ago

Resolution: Rejected
Status: acceptedclosed

Modify Ticket

Action
as closed The owner will remain Nutster.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.