.call also has different behaviour when it comes to objects.
Code: Select all
class Functor {
static info := "Functor class"
info2 := "Functor instance"
__call(functionName, parameter) {
global instance
Msgbox % "this pointer:`t`t" &this . "`nfunctor instance pointer:`t" . &instance . "`ncalled method:`t`t" . functionName . "`nparameter passed:`t`t" . parameter
if ObjhasKey(this, "call") {
target := this.call
%target%()
}
}
}
instance := new Functor()
%instance%("Hello World")
instance.call("Hello World")
instance.call := "callMe"
%instance%("Hello World")
instance.call("Hello World")
callMe() {
Msgbox success
}
Of course there is a reccomendation in the docs that you should use a specific pattern that is similar to what I do here.
However I do not think that even half of the people using these techniques know of that pattern.
This is not a matter of preference. object.call() is not %object%() the 2 are neither interchangeable nor equivalent.
%%() follows most of the established standards AHK has to offer. .call is an alternative that imo does more harm than good since its incompatible with a few aspects of the language.
.call is not a valid option for the general use of calling callables.
Use an objectively worse alternative due to personal bias or grow up and do the right thing - your choice.