Added Method Functionality
Posted: 18 May 2020, 23:27
I have two ideas:
1.)
In a class there's all kinds of things you can do with a method, but sometimes you want to have private and public functions for people to use.
For example, I have a method that displays a message, and another that adds an index for how many times the method's been called:
Some languages have it where you can specify which is public and which is private before the method name.
Some others have it with a built in variable that's an array of all of the method's names.
It would be nice to have a way to only allow certain methods to be called inside the class instead of letting the user call any method they want and possibly cause problems.
2.)
Documentation of a method inside a class is very useful at times. Python does this by having three double quotes just under the function definition:
Doing something for AHK shouldn't be too hard right...? I'd say have some sort of meta function that defines the documentation of the methods.
Just a thought
1.)
In a class there's all kinds of things you can do with a method, but sometimes you want to have private and public functions for people to use.
For example, I have a method that displays a message, and another that adds an index for how many times the method's been called:
Code: Select all
Loop, 4
Messages.Alert("I've been called at least: ")
Return
Class Messages {
Alert(Text) {
MsgBox, 0x0, Alert!, % Text . This.__Times__()
}
; We only want to allow this function to be called inside the class, not outside!
__Times__() {
Static I := 0
I += 1
Return, (I)
}
}
Some others have it with a built in variable that's an array of all of the method's names.
It would be nice to have a way to only allow certain methods to be called inside the class instead of letting the user call any method they want and possibly cause problems.
2.)
Documentation of a method inside a class is very useful at times. Python does this by having three double quotes just under the function definition:
Code: Select all
def my_function():
"""I just display True so..."""
return True
Just a thought