Skip to content
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

Give human-readable names to functions in InstallMethod #3420

Merged
merged 1 commit into from
May 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion lib/oper1.g
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ BIND_GLOBAL( "INSTALL_METHOD",
rank,
method,
oreqs,
req, reqs, match, j, k, imp, notmatch, lk;
req, reqs, match, j, k, imp, notmatch, lk, funcname;

if IsHPCGAP then
# TODO: once the GAP compiler supports 'atomic', use that
Expand Down Expand Up @@ -601,6 +601,31 @@ BIND_GLOBAL( "INSTALL_METHOD",
fi;
fi;

if IS_FUNCTION(method) and IsBound(HasNameFunction) and
IsBound(TYPE_FUNCTION_WITH_NAME) and IsBound(TYPE_OPERATION_WITH_NAME) and
not VAL_GVAR("HasNameFunction")(method) then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, I am in principle fine with keeping this as is, but here's an alternative that might perhaps be a bit easier to read, and which would ensure that the handful of methods which are installed before HasNameFunction is defined properly get names, too: Right before this function, insert HasNameFunction := ReturnFalse;, possibly with a comment explaining what's going on. Then Unbind(HasNameFunction); right before HasNameFunction is actually defined. And here, we can then simply return to the original form, i.e.:

     if IS_FUNCTION(method) and HasNameFunction(method) then

and of course similar for the rank function

funcname := SHALLOW_COPY_OBJ(NAME_FUNC(opr));
APPEND_LIST_INTR(funcname, " ");
if info <> false then
APPEND_LIST_INTR(funcname, info);
ChrisJefferson marked this conversation as resolved.
Show resolved Hide resolved
else
APPEND_LIST_INTR(funcname, "method");
fi;
SET_NAME_FUNC(method, funcname);
fi;

if IS_FUNCTION(rank) and IsBound(HasNameFunction) and
IsBound(TYPE_FUNCTION_WITH_NAME) and IsBound(TYPE_OPERATION_WITH_NAME) and
not VAL_GVAR("HasNameFunction")(rank) then
funcname := "Priority calculation for ";
APPEND_LIST_INTR(funcname, NAME_FUNC(opr));
if info <> false then
APPEND_LIST_INTR(funcname, " ");
APPEND_LIST_INTR(funcname, info);
fi;
SET_NAME_FUNC(rank, funcname);
fi;
fingolfin marked this conversation as resolved.
Show resolved Hide resolved

# Install the method in the operation.
INSTALL_METHOD_FLAGS( opr, info, rel, flags, rank, method );

Expand Down
Loading