Modify

Opened 18 years ago

Closed 16 years ago

#508 closed Feature Request (Completed)

Static variables

Reported by: cbruce Owned by: Nutster
Milestone: 3.3.1.4 Component: AutoIt
Version: Severity: Blocking
Keywords: static variable scope Cc:

Description

AutoIt is a wonderful product folks - thank you so much...

It would be nice to see Static variables added to AutoIt. A Static variables is defined as a variable whose scope is local to a function, but that maintains its value between invocations of the function that the Static variable resides in.

Currently, I have to use Global variables to achieve this effect. This creates a greater opportunity for introducing bugs in a program. [Man, does it ever - I just bit myself again - 3 hours of debugging - the impetus for submitting this feature request]. With Static variables, there is less dependence on the programmer's memory.

I love, and need, Global variables; but the addition of Static variables would make me a more productive programmer in AutoIt.

Respectfully,
Bruce Huber

Attachments (0)

Change History (11)

comment:1 by Gary, 18 years ago

look at "Global Const"

comment:2 by Valik, 18 years ago

Resolution: Rejected
Status: newclosed

Gary, the value needs to be mutable. For example, a counter for the number of times a function is called could be implemented as a static variable (or global, obviously).

cbruce, much like many other things that some other languages offer as "features", you can do this yourself. It just requires you to develop your own rigid naming system to prevent collisions. For example, a name in the form "$g_vStatic_MyVar" will help reduce collisions. Adding the function name in can help disambiguate names further at the cost of increased length in the name.

Closing as rejected.

comment:3 by Valik, 18 years ago

Err, that should have been two $[underscore][underscore]g. Apparently I accidentally triggered the wiki's underline thing.

comment:4 by TicketCleanup, 18 years ago

Version: 3.2.12.1

Automatic ticket cleanup.

comment:5 by Gary, 18 years ago

Valik your correct, I was thinking one thing and posted along another thought line.

An example of what Valik is stating can be found in UDFGlobalID.au3 ( $_UDF_GlobalIDs_Used) where I named it so it shouldn't be reused anywhere.

The above variable is an array but you should get the drift of the idea.

in reply to:  5 comment:6 by cbruce, 18 years ago

Like I say, it's more work for the programmer - but an absolutely pragmatic approach. I'll start using this type of naming convention in AutoIt.

Thanks folks,
Bruce

comment:7 by Nutster, 16 years ago

Milestone: Future Release
Resolution: Rejected
Status: closedreopened

I'll start working on this.

comment:8 by Nutster, 16 years ago

Owner: set to Nutster
Status: reopenedaccepted

comment:9 by TicketCleanup, 16 years ago

Milestone: Future Release

Automatic ticket cleanup.

comment:10 by Valik, 16 years ago

Severity: NoneBlocking

comment:11 by Nutster, 16 years ago

Milestone: 3.3.1.4
Resolution: Completed
Status: acceptedclosed

Added in version: 3.3.1.4

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.