If I understand the problem I think I can help, but what I propose is a bit weird. I think you have a package that uses the unqualified Symbol name Order
internally, and you need the package not to see the System`Order
Symbol while it is defined. To effect this you can temporarily change the Context
of Order
, then put it back after loading the package.
As an example here is a bare-bones package defining a function foo
that uses an internal definition for Order
:
BeginPackage["MyStuff`"]
foo::usage = "my function";
Begin["`Private`"]
Order[args___] := {args} === Sort[{args}];
foo[a_, b_] := If[Order[a, b], "Arguments are in order", "Arguments are out of order"]
End[]
EndPackage[]
After saving this to foo.m
if I call Get[foo.m]
and try to use foo
I have a problem:
Get["foo.m"]
foo[1, 2]
SetDelayed::write: Tag Order in Order[args___] is Protected. >>
If[1, "Arguments are in order", "Arguments are out of order"]
But if, after restarting the kernel, I first move Order
out of the System
context before loading the package:
Context[System`Order] = "hold`";
Get["foo.m"]
Context[hold`Order] = "System`";
I can now call my foo
as intended:
foo[1, 2]
foo[4, 2]
"Arguments are in order"
"Arguments are out of order"
This works because while the package is being defined Order
is not found in the context path, and a new Symbol MyStuff`Private`Order
is created and defined instead:
Definition[foo]
foo[MyStuff`Private`a_, MyStuff`Private`b_] :=
If[MyStuff`Private`Order[MyStuff`Private`a, MyStuff`Private`b],
"Arguments are in order",
"Arguments are out of order"]
And Order
still works elsewhere as its context is restored:
Order["a", "b"]
1