Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Global static variable declaration (+ initialization) inside of a function


  • Please log in to reply
2 replies to this topic
trismarck
  • Members
  • 390 posts
  • Last active: Nov 25 2015 12:35 PM
  • Joined: 02 Dec 2010

Should fun1() return compiler error if global variables initialized at load-time are not supported yet?

 

Related thread: link.

;~ fun1()
;~ fun2()
;~ fun3()
;~ fun4()
;~ fun5()
return

fun1() {
    global static var := 3
    static global var := 3
        ; compiles
}
fun2() {
    static
    local global static var := 3
        ; compiles
}
fun3() {
    static
    global var := 3 ; global var
}
fun4() {
    global
    static var := 3 ; _local_ static var
}
fun5() {
    global static var := 3 ; don't know how to interpret this (see ListLines)
    ; it looks like the expression mode though
}

New Autohotkey forum: http://ahkscript.org.


Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
AutoHotkey doesn't attempt to detect every error that a user can make. This particular error doesn't even seem like one that anyone would make unintentionally. v2 already detects all of the errors in your post (by requiring that only a comma or assignment operator follows the variable name), but I'm not inclined to back-port the changes to v1.

trismarck
  • Members
  • 390 posts
  • Last active: Nov 25 2015 12:35 PM
  • Joined: 02 Dec 2010

AutoHotkey doesn't attempt to detect every error that a user can make. This particular error doesn't even seem like one that anyone would make unintentionally.

 

Well yeah, not _every_ one, but maybe this one. Hehe. Just joking.

 

AutoHotkey doesn't attempt to detect every error that a user can make.

 

For some reason, this statement constantly bothers me because it limits the user friendliness.


New Autohotkey forum: http://ahkscript.org.