@mikeyww that is only about initialization of classes and property initializers in a class. It does not relate to static variables in a function, although the differences from v1 (and relation to initialization of global variables mentioned in the quote) are similar.
The use of static to auto-execute a function is directly addressed under "Variables" in that same document.
Local static variables are initialized if and when execution reaches them, instead of being executed in linear order before the auto-execute section begins. Each initializer has no effect the second time it is reached. Multiple declarations are permitted and may execute for the same variable at different times. There are multiple benefits:
- When a static initializer calls other functions with static variables, there is less risk of initializers having not executed yet due to the order of the function definitions.
- Because the function has been called, parameters, A_ThisFunc and closures are available (they previously were not).
- A static variable can be initialized conditionally, adding flexibility, while still only executing once without requiring if IsSet().
- Since there may be multiple initializers for a single static variable, compound assignments such as static x += 1 are permitted. (This change reduced code size marginally as it was already permitted by local and global.)
Note: static init := somefunction() can no longer be used to auto-execute somefunction. However, since label-and-return based subroutines can now be completely avoided, the auto-execute section is able to span the entire script.
Source: Changes from v1.1 to v2.0 | AutoHotkey v2
I wouldn't call the old behaviour "functionality". If you want the file to be self-contained, you can place the function call in the same file as the definition - above the start of the function definition instead of below it. If you want the call to occur at a particular point in the startup sequence of the script, you can place the #include accordingly. In v1 this was further complicated by static initializers being taken out of sequence with the rest of the script, while still being strictly limited to the sequence they are defined.