Obviously one would not define the class with the intention of not using it, but you can still use it before or after reassigning the
variable.
For example:
Code: Select all
dostuff()
dostuff() {
static x := Msg(config.file)
}
class config extends config._base {
file := "config.ini"
;...
class _base {
__get(p*) {
this.base := ""
config := new config
return config[p*]
}
}
}
Msg(m) {
MsgBox % m
}
Based on
constant values in static/class variables.
I might consider making class names read-only identifiers (not
variable) in v2. It would not reduce flexibility much since one can still clone the class and modify the original object as needed. However, the current framework has no provision for
constants, and #Warn already gets the job done. Also, consider the fact that nested classes are (in current versions of the language) simply assigned to array elements, and a
constant array element doesn't make much sense.
(#Warn ClassOverwrite is implemented by checking the code for assignments to variables which
already contain an object before the script executes.)