diff --git a/doc/ref/create.xml b/doc/ref/create.xml index 674c0faeaf..f06b70952f 100644 --- a/doc/ref/create.xml +++ b/doc/ref/create.xml @@ -1195,6 +1195,7 @@ See also Section . <#Include Label="DeclareSynonym"> <#Include Label="FlushCaches"> <#Include Label="FilterByName"> +<#Include Label="ShowDeclarationsOfOperation"> diff --git a/lib/methwhy.g b/lib/methwhy.g index 381b3227b3..12cbcedb5e 100644 --- a/lib/methwhy.g +++ b/lib/methwhy.g @@ -388,6 +388,52 @@ BIND_GLOBAL("ShowImpliedFilters",function(filter) fi; end); + +############################################################################# +## +#F ShowDeclarationsOfOperation( ) +## +## <#GAPDoc Label="ShowDeclarationsOfOperation"> +## +## +## +## +## Displays information about all declarations of the operation oper, +## including the location of each declaration and the argument filters. +## ShowDeclarationsOfOperation(IsFinite); +## Available declarations for operation : +## 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 ] +## ]]> +## +## +## <#/GAPDoc> +## +BIND_GLOBAL("ShowDeclarationsOfOperation",function(oper) + local locs, reqs, i, r; + if not IsOperation(oper) then + Error(" 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