It would be quite useful if KerboScript had an ASSERT function. The idea would be that if its argument is true, it has no effect, but if its argument is false, the script terminates with an error message that points to the failing assertion. This would let you do all kinds of useful parameter and state validation without having to "protect" everything after the check, or otherwise arrange proper flow control for the error case. Something similar is discussed in #125, but there it gets entangled with the whole function-call can of worms. I think that's unnecessary for this use case: an ASSERT should terminate not only the immediate function, but all its callers as well, so the question of return values does not arise.
Not only would this be a very useful feature, it also seems appealing from an RP point of view: assertions strike me as a very Kerbal form of error handling.
It would be quite useful if KerboScript had an
ASSERT
function. The idea would be that if its argument is true, it has no effect, but if its argument is false, the script terminates with an error message that points to the failing assertion. This would let you do all kinds of useful parameter and state validation without having to "protect" everything after the check, or otherwise arrange proper flow control for the error case. Something similar is discussed in #125, but there it gets entangled with the whole function-call can of worms. I think that's unnecessary for this use case: anASSERT
should terminate not only the immediate function, but all its callers as well, so the question of return values does not arise.Not only would this be a very useful feature, it also seems appealing from an RP point of view: assertions strike me as a very Kerbal form of error handling.