Modify

Opened 5 years ago

Last modified 5 years ago

#2855 new Feature Request

Scoping and declaration modifiers combinations

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

Description

Static is currently forbidden in combination with Enum and Const but these that can be needed in the real world.

Dim $a1
Local $a2
Global $a3
Static $a4
Local Static $a5
Global Static $a6
Enum $a7
Dim Enum $a8
Local Enum $a9
Global Enum $a10
;~ Static Enum $a11              ; ==> No variable given for "Dim", "Local", "Global", "Struct" or "Const" statement.
;~ Local Static Enum $a12        ; ==> No variable given for "Dim", "Local", "Global", "Struct" or "Const" statement.
;~ Global Static Enum $a13       ; ==> No variable given for "Dim", "Local", "Global", "Struct" or "Const" statement.
Const $a14 = 0
Dim Const $a15 = 1
Local Const $a16 = 2
Global Const $a17 = 3
;~ Static Const $a18 = 4         ; ==> No variable given for "Dim", "Local", "Global", "Struct" or "Const" statement.
;~ Local Static Const $a19 = 5   ; ==> No variable given for "Dim", "Local", "Global", "Struct" or "Const" statement.
;~ Global Static Const $a20 = 6  ; ==> No variable given for "Dim", "Local", "Global", "Struct" or "Const" statement.
Const Enum $a21
Dim Const Enum $a22
Local Const Enum $a23
Global Const Enum $a24
;~ Static Const Enum $a25        ; ==> No variable given for "Dim", "Local", "Global", "Struct" or "Const" statement.
;~ Local Static Const Enum $a26	 ; ==> No variable given for "Dim", "Local", "Global", "Struct" or "Const" statement.
;~ Global Static Const Enum $a27 ; ==> No variable given for "Dim", "Local", "Global", "Struct" or "Const" statement.

Static Enum and Static Const (Local or Global) are useful to allow skipping subsequent lengthy or "runonce" initialization (e.g. having side-effects).

<*> Const Enum are harmless redondancies since Enums are constant, so Static Const Enum (Local or Global) should work as well.

BTW what is this "Struct" statement mentionned in the error message? (It is also recognized as a keyword in SciTE.)

Attachments (0)

Change History (7)

comment:1 Changed 5 years ago by TicketCleanup

  • Version 3.3.12.0 deleted

Automatic ticket cleanup.

comment:2 Changed 5 years ago by anonymous

agree. Especially lacking Local Static Const

comment:3 Changed 5 years ago by jchd18

Of course this one, yet Local Static Const Enum might be required as well as some others. All combinations even if less useful or meaningful would be welcome, just for symetry and denoting intention.

Only contradictory (Local Global $a) or badly formed (Global Const Static $a) should be denied.

comment:4 Changed 5 years ago by Jpm

I still hate the Local being Global when declares in the main script ...

comment:5 Changed 5 years ago by jchd18

Lacking file scope I still find it valuable as a hint of the intended scope, albeit in practice it can be subverted as if it were global. But this is a completely distinct matter.

BTW JP, do you have the faintest idea about "Struct"? Was that a typo for "Static" or something left over from very old versions?

comment:6 Changed 5 years ago by anonymous

Where would a Static Constant ever be used, and for what? If it's a constant, there's no need to use Static because you can set it once at the beginning of a function and never have to worry about what it is the next time you run your function. Static only allows the contents of a variable to remain valid after the function ends, and then is visible again after the function is called again.

Also, Global Static is completely pointless.

comment:7 Changed 5 years ago by jchd18

You forget the case where a constant initialization is not a literal or an expression with fixed value but the result of a computation with side-effect or randomization. If you don't tag it with Static, you'll go thru initialization again at every invokation of the function, and the constant will have a new value every time (or cause other nasty side-effect, depending on context).

Some other combinations could be allowed even if semantically pointless, just to denote intent.

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 new 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.