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

Add ShowDeclarationsOfOperation helper #3459

Merged
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
1 change: 1 addition & 0 deletions doc/ref/create.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1195,6 +1195,7 @@ See also Section <Ref Sect="More About Global Variables"/>.
<#Include Label="DeclareSynonym">
<#Include Label="FlushCaches">
<#Include Label="FilterByName">
<#Include Label="ShowDeclarationsOfOperation">

</Section>

Expand Down
46 changes: 46 additions & 0 deletions lib/methwhy.g
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,52 @@ BIND_GLOBAL("ShowImpliedFilters",function(filter)
fi;
end);


#############################################################################
##
#F ShowDeclarationsOfOperation( <oper> )
##
## <#GAPDoc Label="ShowDeclarationsOfOperation">
## <ManSection>
## <Func Name="ShowDeclarationsOfOperation" Arg='oper'/>
##
## <Description>
## Displays information about all declarations of the operation <A>oper</A>,
## including the location of each declaration and the argument filters.
## <Log><![CDATA[
## gap> ShowDeclarationsOfOperation(IsFinite);
## Available declarations for operation <Property "IsFinite">:
## 1: GAPROOT/lib/coll.gd:1451 with 1 arguments, and filters [ IsListOrCollection ]
## 2: GAPROOT/lib/float.gd:212 with 1 arguments, and filters [ IsFloat ]
## 3: GAPROOT/lib/ctbl.gd:1195 with 1 arguments, and filters [ IsNearlyCharacterTable ]
## ]]></Log>
## </Description>
## </ManSection>
## <#/GAPDoc>
##
BIND_GLOBAL("ShowDeclarationsOfOperation",function(oper)
local locs, reqs, i, r;
if not IsOperation(oper) then
Error("<oper> must be an operation");
fi;
Print("Available declarations for operation ", oper, ":\n");
locs := GET_DECLARATION_LOCATIONS(oper);
if locs = fail then
return;
fi;
reqs := GET_OPER_FLAGS(oper);
for i in [1.. Length(locs)] do
r := List(reqs[i], r -> JoinStringsWithSeparator(NamesFilter(r), " and \c"));
Print(String(i, 3), ": ", locs[i][1], "\c:", locs[i][2], "\c",
" with ", Length(reqs[i]), "\c",
" arguments, and filters [ ", "\c",
JoinStringsWithSeparator(r, ", "),
" ]\n"
);
od;
end);


#############################################################################
##
#F PageSource( func ) . . . . . . . . . . . . . . . show source code in pager
Expand Down