Repository navigation
Remove unnecessary Output.flushs before Global.exit and Global.crash - #535
Merged
Merged
Conversation
added 3 commits
July 10, 2022 11:16
I'm not sure about this one. Please verify.
Collaborator
|
Thank you |
Author
|
@Jarred-Sumner thank you for merging. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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'scodeparameter 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.crashtoGlobal.failbecauseGlobal.crashcan 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)