Modify

Opened 4 years ago

Closed 4 years ago

#3131 closed Feature Request (Rejected)

Add a "safe" modifier to ReDim to preserve Dimensions

Reported by: minxomat Owned by:
Milestone: Component: AutoIt
Version: Severity: None
Keywords: Cc:

Description

This is a request for a modifying keyword (or alternatively an Opt flag) to warn the user when he tries to redim with different dimensions (trashing the old array). Example:

; (1) Runs and trashes old array:
Local $aTest[0][0]
ReDim $aTest[1]

; (2) Breaks with an error / warning:
Local $bTest[0][0]
ReDim Safe $bTest[1]

Attachments (0)

Change History (3)

comment:1 Changed 4 years ago by BrewManNH

How exactly are you expecting this to work? Are you expecting the script to display an error and exit at this point? That would make it a debugging feature, and debugging features should never be in production code by default.

Wouldn't this be up to the person writing the script to not do something like this? I can understand a bit of hand holding, but this is training wheels for bad coders isn't it?

comment:2 Changed 4 years ago by minxomat

(1)

Wouldn't this be up to the person writing the script to not do something like this?

Well, it's kind of the same deal with constants, where if you try to change a constant, it breaks with an error.

(2)

An analogy is Visual Basic, where if you ReDim Preserve an array, every other feature remains untouched (such as types). AutoIt's ReDim is preserving by default, but it trashes the old array. That's not an argument, rather a look how this is handled in other languages.


Another (way) less complicated way to do this would be to provide an Opt flag much in the same way as MustDeclareVars. Something along the lines of MustPreserveDimension. Actually, I think this would probably be the better way.

comment:3 Changed 4 years ago by Melba23

  • Resolution set to Rejected
  • Status changed from new to closed

minxomat,

As Jon has clearly stated there will be no further Opt flags you can forget that.

I not of the opinion that this is something that needs to be "checked" by AutoIt - it must be the responsibility of the coder to do check that any ReDim is correctly written.

M23

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.