Modify

Opened 15 years ago

Closed 12 years ago

Last modified 8 years ago

#1191 closed Feature Request (Completed)

Make explicit size of arrays optional when have explicit initialization

Reported by: jchd Owned by: trancexx
Milestone: 3.3.9.3 Component: AutoIt
Version: Severity: None
Keywords: Cc:

Description

Would it be possible that the declaration of arrays doesn't mandate explicit sizes.

$ar[4] = [ 'I', 'have', 'four', 'elements!']

could then be:
$ar[] = [ 'I', 'have', 'four', 'elements!']

and UBound($ar) would then yield 4. Of course, declaring a larger size than number of initializers wouldn't be an error.

I ask because it's very irritating to have to count things when you code initialy, or after you paste a bunch of elements from elsewhere.

Attachments (0)

Change History (8)

comment:1 Changed 15 years ago by TicketCleanup

  • Version 3.3.1.1 deleted

Automatic ticket cleanup.

comment:2 Changed 15 years ago by Manadar

Or: Local $ar = [ 'I', 'have', 'four', 'elements!']

comment:3 follow-up: Changed 15 years ago by Nutster

  • Owner set to Nutster
  • Status changed from new to assigned

In order to make the initialization assignment efficient, the variable gets created first, then the initialization values are assigned to the array elements directly. In order to allow this syntax,

Local $aArray[] = ['This', 'is', 'a', 'test.']

the initializer would need to be read twice, once to determine its size and a second time to assign the values to the array. I will investigate how to do this in a most practical and efficient manner.

I think I will need the empty brackets after the variable name as a marker that I should be looking for array initializers and that I will need to perform the double scan of the initializer.

Local $aArray = ['Pain', 'in', 'the', 'neck', 'array']

This version will not be happening.

comment:4 in reply to: ↑ 3 Changed 15 years ago by anonymous

I think I will need the empty brackets after the variable name as a marker that I should be looking for array initializers and that I will need to perform the double scan of the initializer.

I was suspecting this, so my initial request was suggesting this form. It's also more similar to C and friends and very intuitive.

Do you think you'll be able to generalize to any dimension, as in:

Local $aArray[2][][3] = [ ...

Also since you are at it, can it be made possible to have empty (sub-dimension) initializers:

Local $a2Array[4][3] = [[5], [6, 2, 8], [1], [9, 7]] ;; works fine
Local $a2Array[4][3] = [[5], [6, 2, 8], [], [9, 7]]  ;; current versions chokes at '[]'
Local $a2Array[][]   = [[5], [6, 2, 8], [], [9, 7]]  ;; would be a must

This isn't exactly the same request but it's so close that I don't want to open yet another ticket.

comment:5 follow-up: Changed 15 years ago by Nutster

AutoIt does not have a legal undefined value, like perl or some other languages. You need to explicitly declare a value in [], even if "" or 0. Without more detail of what [] is supposed to do, this is not going to happen.

comment:6 in reply to: ↑ 5 Changed 15 years ago by jchd <jcd@…>

Replying to Nutster:

AutoIt does not have a legal undefined value, like perl or some other languages. You need to explicitly declare a value in [], even if "" or 0. Without more detail of what [] is supposed to do, this is not going to happen.

Sorry but this doesn't sound very consistent with current behavior. E.g. what value is then given to undeclared elements in $aTest[5] = [1] ?
Since in the multi-dimension scenario, after first pass you know which is the "convex enveloppe" (max dimensions) of the hole thing, I hardly see your point.

comment:7 Changed 12 years ago by trancexx

  • Milestone set to 3.3.9.3
  • Owner changed from Nutster to trancexx
  • Resolution set to Completed
  • Status changed from assigned to closed

Added by revision [6882] in version: 3.3.9.3

comment:8 Changed 8 years ago by anonymous

Spam link removed.

Last edited 8 years ago by jchd18 (previous) (diff)

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 owner will remain trancexx.
Author


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

 
Note: See TracTickets for help on using tickets.