Remove unnecessary Output.flush
s before Global.exit
and Global.crash
#535
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I thought about this a bit more and realized that we could remove
Global.exit
'scode
parameter because in 99.5% of all cases we only ever exit with either 1 or 0, so we could actually makeGlobal.crash()
always exit with 1 (which it does already) andGlobal.exit()
always exit with 0, indicating failure and success, respectively. We might also want to renameGlobal.crash
toGlobal.fail
becauseGlobal.crash
can mislead people that it's only called when a bug is encountered. And we should explicitly mention in the docs of those two that they already flush output. This way we can prevent these mistakes in the future.Or maybe we could only have one function that exits and we let it take an
enum
. So you can doGlobal.exit(.error)
andGlobal.exit(.success)
. I think that might actually be the best and most readable solution.In fact we could make it a
union(enum)
and allowexit(.{ .custom = 50 });
too for codes that are not 0 or 1.Should I do the above in a followup PR?
This PR would be in preparation for that.
Additionally, the first commit fixes this issue I found:
(missing newline)