Skip to content
Closed
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
57 changes: 57 additions & 0 deletions gap/obsolete.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
InstallDeprecatedMethod := function(oldName, newName, info, filters, func)
local warningMsg, newMethod, args;
warningMsg := Concatenation(oldName, " is deprecated. Instead use ",
newName, ".");

args := Length(filters);
if args = 0 then
newMethod := function()
Warning(warningMsg);
return func();
end;
elif args = 1 then
newMethod := function(a)
Warning(warningMsg);
return func(a);
end;
elif args = 2 then
newMethod := function(a, b)
Warning(warningMsg);
return func(a, b);
end;
elif args = 3 then
newMethod := function(a, b, c)
Warning(warningMsg);
return func(a, b, c);
end;
elif args = 4 then
newMethod := function(a, b, c, d)
Warning(warningMsg);
return func(a, b, c, d);
end;
elif args = 5 then
newMethod := function(a, b, c, d, e)
Warning(warningMsg);
return func(a, b, c, d, e);
end;
elif args = 6 then
newMethod := function(a, b, c, d, e, f)
Warning(warningMsg);
return func(a, b, c, d, e, f);
end;
else
Error("Unsupported args: ", args);
Copy link
Member

Choose a reason for hiding this comment

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

You could just do:

newMethod := function(args...)
  Warning(warningMsg);
   return CallFuncList(fun, args);
end;

Copy link
Member

Choose a reason for hiding this comment

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

Ah this doesn't work, hmmm

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@james-d-mitchell sir, should I update this to your suggestion or try an alternative route? Or is the current implementation correct?

fi;

InstallMethod(oldName, info, filters, newMethod);
end;

DeclareDeprecatedSynonym := function(oldName, newName)
local i, method;
for i in [0 .. 6] do
for method in MethodsOperation(newName, i) do
InstallDeprecatedMethod(oldName, NameFunction(newName),
method.info, method.argFilt, method.func);
od;
od;
end;
2 changes: 2 additions & 0 deletions gap/obsolete.gi
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Read("obsolete.gd");
DeclareDeprecatedSynonym("DigraphDijkstra", DigraphShortestPaths);
Loading