Code: Select all
MsgBox(Click())
MsgBox(MouseClick())
So Click should return empty string just like MouseClick, not a magic number 5369740240.
Code: Select all
MsgBox(Click())
MsgBox(MouseClick())
Why should it? The return value is undefined. It is not defined anywhere to be an empty string or anything else. It can be anything or nothing with no consequence to a script that is following the documentation. Since the return value is undefined, then there is no reason for a script to check it or otherwise make use of it. If a script does make use of it and is expecting a certain value, that is an issue with the script, not AHK.
That doesn’t matter. Those are also undefined, and you can not and should not count on them returning that value (or lack of value).
https://www.autohotkey.com/docs/v2/Functions.htmIf the flow of execution within a function reaches the function's closing brace prior to encountering a Return, the function ends and returns a blank value (empty string) to its caller. A blank value is also returned whenever the function explicitly omits Return's parameter.
The documentation for functions written in AHK have nothing to do with how AHK itself is written. It makes no sense to apply the syntax rules and behavior defined in the documentation for AHK code to the underlying C++ code that the language itself, including the Click() function, was written in. That code needs to be compliant with C++ rules.
It absolutely does not mean that. You are quoting rules for code written in AHK. Click() is not a function written in AHK, so doesn’t follow AHK’s syntax and therefore doesn’t follow these rules. And there’s nothing that says it doesn’t return a value. Its return value is not defined. It may return a value or maybe it does not, and you as a coder of AHK can make no inferences about whether it does or does or doesn’t, or what its value may be if it does because the return value is not defined.
The reply is ridiculous. Essentially, ZhuangQu is saying Click() should NOT RETURN anything (or "" if you look at it that way). That is because, when Click() DOES RETURN something, we have every reason to assume IT WAS FOR A REASON.ZhuangQu wrote: ↑
So Click should return empty string just like MouseClick, not a magic number 5369740240.
Boiler replied:
Why should it? The return value is undefined. It is not defined anywhere to be an empty string or anything else. It can be anything or nothing with no consequence to a script that is following the documentation. Since the return value is undefined, then there is no reason for a script to check it or otherwise make use of it. If a script does make use of it and is expecting a certain value, that is an issue with the script, not AHK.
However you may wish to characterize the programming, if it doesn't violate the documented behavior and doesn't cause code that conforms to the documentation to misbehave or crash, it's not a bug. You don't get to make up your own definition of a bug, even if you write it in all-caps.
Yes, we should all feel free do so in a respectful manner.
I am not aware of that being stated anywhere, and apparently Descolada, who knows the language more thoroughly than I do, is not either. You might be interested in making a post in Suggestions on Documentation Improvements suggesting such.
So true!!! I've often imagined just how much in languages and programs is not documented for that very reason. Having programmed--and still doing so as a retired programmer--for over 50 years, I long ago learned the VALUE in documentation. Youngsters need to. Try figuring out a tricky algorithm 10 years after you write it.@Boiler wrote:
so the AHK developer has the right to change how that works without it being considered breaking backward compatibility.