Re: Will AutoHotkey v2 Syntax Be More Confusing For Newbies?
Posted: 09 May 2019, 18:37
I disagree with the points of view that any part of v1 is easier or less confusing. v2 requires learning a few trivial things earlier on (like how to quote strings), but in the process removes so many points of confusion that v1 retains.
Labels are more verbose and more error-prone. Gosub is the same as a function call. Labels are the same as function definitions, except that their bounds are not clearly defined and they are effectively always assume-global. Users often fail to return at the appropriate point, or misuse Gosub as a form of Goto.
If you have some problem with the concept or use of local variables, get help or use assume-global.
More importantly, it sounds like parties on both sides of the debate believe that labels have been taken away, or will be. I have no intention of removing labels in v2.0.
I don't clearly recall my reason for changing SetTimer, Menu, OnX, etc. to not accept labels; it probably related to local labels. The ability to call a label inside a function from outside and refer to local variables while that function is not running (or while a different instance of that function was running) was strange and error-prone. Nested functions are not subject to the same problems.
Assuming I don't restore the capability for SetTimer etc. to call global labels, you can work around it with a simple helper function:Label(n) => () => gosub(n) doesn't work because gosub is a control flow statement, not a function.
You don't need to fully understand classes, OOP concepts or objects to use objects, any more than you need to understand the syntax of every single command to use just one command. You can just memorize the syntax for a given task; except that it's near impossible to completely memorize the awkward Gui command syntax. Breaking things down into simpler, more common patterns makes the whole easier to learn.
That is frankly absurd.Label, Gosub, Return are easier to understand and use than functions, [...]
Labels are more verbose and more error-prone. Gosub is the same as a function call. Labels are the same as function definitions, except that their bounds are not clearly defined and they are effectively always assume-global. Users often fail to return at the appropriate point, or misuse Gosub as a form of Goto.
If you have some problem with the concept or use of local variables, get help or use assume-global.
More importantly, it sounds like parties on both sides of the debate believe that labels have been taken away, or will be. I have no intention of removing labels in v2.0.
I don't clearly recall my reason for changing SetTimer, Menu, OnX, etc. to not accept labels; it probably related to local labels. The ability to call a label inside a function from outside and refer to local variables while that function is not running (or while a different instance of that function was running) was strange and error-prone. Nested functions are not subject to the same problems.
Assuming I don't restore the capability for SetTimer etc. to call global labels, you can work around it with a simple helper function:
Code: Select all
SetTimer Label("There"), -1
return
There:
MsgBox A_ThisLabel
return
Label(n) {
LabelCall() {
gosub(n)
}
return Func("LabelCall")
}
You don't need to fully understand classes, OOP concepts or objects to use objects, any more than you need to understand the syntax of every single command to use just one command. You can just memorize the syntax for a given task; except that it's near impossible to completely memorize the awkward Gui command syntax. Breaking things down into simpler, more common patterns makes the whole easier to learn.