Descolada wrote: ↑01 Sep 2023, 07:55
Concept-wise, in my opinion errors are serious problems in code from which the code cannot recover from on its own nor can continue without addressing the error.
If a function cannot fulfill its purpose, that is an error condition. If a function's purpose is to send keys while buffering the user's input, it cannot fulfill its purpose if another hook is present. For something like TrySendInput, it would not be an error condition; it is implied that the function's purpose is to make an
attempt, and the return value would indicate whether it succeeded.
If the code relies on the function to send keys, which is likely, and the keys
aren't sent because it can't use the method which was requested, would it not be generally the case that the code will need to address the problem before continuing?
How would code
recover from a problem without first detecting it, such as by catching an exception? Why is it even considered a
problem if it is not an error?
Warnings on the other hand are problems which *are* recoverable, or signal that under certain conditions (which may or may not have been met) the code might fail or cause problems.
Emphasis on
under certain conditions (that haven't been verified prior to showing the warning) and
might. All current warnings are detected through static analysis of the code before it runs. They are all conditions which
may or may not indicate a mistake that may prevent the code from running correctly.
The current #Warn directives cause "continuable errors", which in my opinion is an oxymoron: it shouldn't be possible to continue after an error, these are in my opinion warnings.
They do not "cause errors". A dialog box or OutputDebug message is not an error. A warning is literally just a warning. It warns.
However, for warnings, I think the default method should be OutputDebug, because a warning doesn't interrupt code flow and neither does OutputDebug.
Why did this topic become about changing the default behaviour of warnings?
I also expect that users who know to enable warnings are also using software that allows for debugging, so OutputDebug seems like the best choice over StdOut or logging to a file.
The directive exists for users who know how to use it. The default behaviour exists for
everyone. Everone, especially users who haven't learned enough to know about warnings, should be warned when they are likely to be making a mistake. It will save them time. Consider what happens if we default to StdOut and the parent process isn't catching or displaying it, or we default to OutputDebug and no debugger is running:
nothing happens.
The user is not warned.
#IfWarn
Something like the C preprocessor's #if has been suggested several times over the decades. Why would you limit it to a "warning" toggle? This is getting a bit far from the original topic.
It might be useful to have a way to throw continuable errors as well, for example with throw Warning("This is continuable and creates a stack-trace like a normal error").
Throw is already continuable in v2.1-alpha.3, which I am preparing for release. As with all continuable errors, it is continuable only if try/catch is not in use.
Exceptions are thrown. Throwing a warning makes no sense. A warning just
warns.
The variables might be useful in other cases as well in addition to being a surrogate to whether Input will revert or not, so this post isn't meant as a replacement for that.
You've lost me again. Variables?