Is it paradoxical to say that static declarations are evaluated in the order that they are encountered in the execution of the script, when execution of the script begins with evaluating static declarations?
I'm not sure what you mean. Perhaps you could show an example?
I have found that when I run my script, all class statics are evaluated first, then the script is executed as I would expect. Example:
z := fn("there")
fn(y)
{
static x := "Hello"
xx := x
x := y
return xx
}
MsgBox % "'" z "' '" fn("") "'"
Outputs a message box that says
'Hello' 'there'
.
The following examples do things that were totally unexpected:
class xx
{
static z := xx.fn("there")
fn(y)
{
static x := "Hello"
xx := x
x := y
return xx
}
; static z := xx.fn("there") ; Doesn't matter if before or after the function xx.fn() definition
}
MsgBox % "'" xx.z "' '" xx.fn("") "'"
outputs a message box that says
'' ''
and:
fn(y)
{
static x := "Hello"
xx := x
x := y
return xx
}
class xx
{
static z := fn("there")
}
MsgBox % "'" xx.z "' '" fn("") "'"
outputs
'' 'there'
and:
class xx
{
static z := fn("there")
}
fn(y)
{
static x := "Hello"
xx := x
x := y
return xx
}
MsgBox % "'" xx.z "' '" fn("") "'"
outputs
'' 'Hello'
and:
class xx
{
fn(y)
{
static x := "Hello"
xx := x
x := y
return xx
}
}
z := xx.fn("there")
MsgBox % "'" z "' '" xx.fn("") "'"
outputs
'Hello' ''
.
The evaluation order of statics is not just limited to where they physically are in the file, but whether they are class statics or function statics. A class static referencing a function static will always get an undefined value as class statics are evaluated prior to anything else it appears. I'm unable to reconcile the class function static example though.
Adrian