v1 & v2 When the class name is greater than the variable assigned to the instance, __Delete cannot get static class vars
Posted: 29 Apr 2021, 20:41
v1
v2
I wish I could make this up, but there is clearly a data race going on somewhere? If the name of the class is s, then all letters before s, including r, a word beginning with r, works. If the letter is greater than the class name, then __Delete fails to retrieve the instance variable. No idea why the name of the variable being assigned to is of significance, unless everything is ordered in AHK alphabetically, and upon ExitApp, everything is unloaded alphabetically, causing class s to be unloaded before variable u, rendering s.__Delete()'s static var invalid?
Code: Select all
class s {
__New() {
this.start()
}
__Delete() {
this.shutdown()
}
static instances := 0
start() {
s.instances++
MsgBox % s.instances
}
shutdown() {
s.instances--
MsgBox % s.instances
if (s.instances < 0)
throw Exception("I don't understand why this error shows.")
}
}
; r := new s() ; Works.
u := new s() ; Doesn't work.
ExitApp
Code: Select all
class s {
__New() {
this.start()
}
__Delete() {
this.shutdown()
}
static instances := 0
start() {
s.instances++
MsgBox s.instances
}
shutdown() {
s.instances--
MsgBox s.instances
if (s.instances < 0)
throw Error("I don't understand why this error shows.")
}
}
; r := s() ; Works.
u := s() ; Doesn't work.
ExitApp