-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rename QUIT_GAP
, FORCE_QUIT_GAP
and GAP_EXIT_CODE
to QuitGap
, ForceQuitGap
and GapExitCode
(the old names remain available as synonyms)
#3862
Conversation
We could decide that QUIT_GAP -> QuitGap is OK, but leave FORCE_QUIT_GAP as all caps, as that function is "less user safe"... |
else | ||
QUIT_GAP(1); | ||
QuitGap(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Independent of this PR: looking at this PR, I discovered SetExitValue
and learned that one could rewrite the above code as QuitGap(testTotalFailures = 0);
. But I am not aware of any code using that. So, is it worth keeping this complication? If so, shouldn't we then actually use it here and elsewhere (perhaps not as part of this PR)?
On the other hand, it seems to me that code like QuitGap(testTotalFailures = 0);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I have used SetExitValue(1), so if GAP exits in the middle of my program (say because of an error), the exit value ends up set to a non-zero value.
Using QUIT_GAP(boolean), I don't remember ever seeing. We could probably remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at packages, there are a couple of QUIT_GAP()
, but no passing in of booleans I can see.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that SetExitValue
is useful to have, yes.
{ | ||
if ( LEN_LIST(args) == 0 ) { | ||
SystemErrorCode = 0; | ||
} | ||
else if ( LEN_LIST(args) != 1 | ||
|| !SetExitValue(ELM_PLIST(args, 1) ) ) { | ||
ErrorQuit( "usage: QUIT_GAP( [ <return value> ] )", 0, 0); | ||
ErrorQuit( "usage: QuitGap( [ <return value> ] )", 0, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, I am not aware of any code calling QuitGap
or ForceQuitGap
without an exit code. Are you? What would be a use case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think I've done it myself. I suppose someone might want to just quit gap, but asking for a return value doesn't feel unreasonable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems all harmless to me (and useful)
4f5cae9
to
c282b74
Compare
src/gap.c
Outdated
** | ||
*/ | ||
|
||
static Obj FuncGAP_EXIT_CODE(Obj self, Obj code) | ||
static Obj FuncGapExitCode(Obj self, Obj code) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So tangentially related to this PR (which BTW needs to be rebased, then it could be merged): I just had need to query the exit code, and there simply is no way to do this. However, the natural name for a function to do this is taken... Can we either rename this to SetGapExitCode
(and then later we can can add GapExitCode
or GetGapExitCode
to query it); or else change this function to return the exit code, and then also to allow calling it with 0 args, to just get the exit code w/o changing it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or how about SetExitCode
-- or for that matter, SetExitValue
which would match the kernel function (or conversely: rename the kernel function to match the function here...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good but needs to be rebased.
I took the liberty of rebasing this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some more tweaks for the documentations
src/gap.c
Outdated
** | ||
*/ | ||
|
||
static Obj FuncGAP_EXIT_CODE(Obj self, Obj code) | ||
static Obj FuncGapExitCode(Obj self, Obj code) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or how about SetExitCode
-- or for that matter, SetExitValue
which would match the kernel function (or conversely: rename the kernel function to match the function here...)
QUIT_GAP
, FORCE_QUIT_GAP
and GAP_EXIT_CODE
to QuitGap
, ForceQuitGap
and GapExitCode
(the old names remain available as synonyms)
A usual gap rule is CamelCase functions are for users, and ALL_CAPS are internal.
I think enough people are now using QUIT_GAP, FORCE_QUIT_GAP and GAP_EXIT_CODE that they should be moved to CamelCase (obviously leaving the old ALL_CAPS versions as obsolete).