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 , 18 years ago
comment:2 by , 18 years ago
| Resolution: | → Rejected |
|---|---|
| Status: | new → closed |
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 , 18 years ago
Err, that should have been two $[underscore][underscore]g. Apparently I accidentally triggered the wiki's underline thing.
follow-up: 6 comment:5 by , 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.
comment:6 by , 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 , 16 years ago
| Milestone: | → Future Release |
|---|---|
| Resolution: | Rejected |
| Status: | closed → reopened |
I'll start working on this.
comment:8 by , 16 years ago
| Owner: | set to |
|---|---|
| Status: | reopened → accepted |
comment:10 by , 16 years ago
| Severity: | None → Blocking |
|---|
comment:11 by , 16 years ago
| Milestone: | → 3.3.1.4 |
|---|---|
| Resolution: | → Completed |
| Status: | accepted → closed |
Added in version: 3.3.1.4

look at "Global Const"