I mean, why now I have to update information that "yes, this var is global, for sure it's global" if I ALREADY choose that in the global scope? Half of my variable are global — and now, with this AHK 2.0 implementation, I have to creep through every function and make a list of global variable that this function uses.
And if before I could write this...
Code: Select all
;Script for AutoHotkey 2 — some alpha build.
global var1 := "value one"
global var2 := "value two"
global var3 := "value three"
function f_a()
{
var1 := "some text one"
MsgBox var1
}
function f_b()
{
var2 := "some text two"
MsgBox var2
}
function f_c()
{
var 3 := "some text three"
MsgBox var3
}
Code: Select all
;Script for AutoHotkey 2.0.2.
global var1 := "value one"
global var2 := "value two"
global var3 := "value three"
function f_a()
{
global var1 ;This strange construction switches us from local var1 to the global one.
var1 := "some text one"
MsgBox var1
}
function f_b()
{
global var2
var2 := "some text two"
MsgBox var2
}
function f_c()
{
global var3
var 3 := "some text three"
MsgBox var3
}
Yes, also it allows my head to be aching every time I'm trying to use global variables inside a function. I've NEVER had any problem with remembering which of my variable are global, so I didn't accidently set a global var instead of local one, and I don't need to make myself a dozen of global var1 reminders in the beginning at every single fracking function that this variable is actually global. Instead, I always use local var1 := "value" construction which is standard for most of programming languages. When rewriting already written function, it becomes even harder to track what variables of script are global or not. By this implementation, you're throwing it back into AHK 1 era, which has simplified as hell for just some housekeeper users could write their shitty two-lines copy-paste script as fast as possible, while more advanced users were suffering of unusable syntax.Any variable reference in an assume-local function may resolve to a global variable if it is only read. However, if a variable is used in an assignment or with the reference operator (&), it is automatically local by default. This allows functions to read global variables or call global or built-in functions without declaring them inside the function, while protecting the script from unintended side-effects when the name of a local variable being assigned coincides with a global variable.
Anyway, what was wrong with the previous implementation? Which was like "if variable already mentioned as global, use the global one; if not, create the local one" or something.
UPD: I guess adding a directive for switching to the previous mode of treating global variable would be very acceptable.