Skip to main content
deleted 1 characters in body
Source Link
Sjoerd C. de Vries
  • 66.1k
  • 15
  • 189
  • 327
  1. After running your Package code the first time Test1` is added to the $ContextPath.

  2. When you call Test1`function1[5] the symbol function1 is created in the context Test1`

  3. After calling BeginPackage["Test1`"] and Begin["`Private`"] the $ContextPath is: {"Test1`","System`"}

  4. When you use function1 in function1[x_] := x it is found in the $ContextPath and therefore it parses as Test1`function1.

To avoid this, you need to either remove the symbol Test1`function1 from the context path before defining function1[x_] := x, or you need to give the context explicitly. Either of these should work:

BeginPackage["Test1`"];
Begin["`Private`"];
Test1`Private`function1[x_] := x
End[];
EndPackage[];

Or:

BeginPackage["Test1`"];
Remove[function1]
Begin["`Private`"];
function1[x_] := x
End[];
EndPackage[];

If you wish to completely resentreset the contents of Test1` every time the package is run you might use Remove["Test1`*"].

  1. After running your Package code the first time Test1` is added to the $ContextPath.

  2. When you call Test1`function1[5] the symbol function1 is created in the context Test1`

  3. After calling BeginPackage["Test1`"] and Begin["`Private`"] the $ContextPath is: {"Test1`","System`"}

  4. When you use function1 in function1[x_] := x it is found in the $ContextPath and therefore it parses as Test1`function1.

To avoid this, you need to either remove the symbol Test1`function1 from the context path before defining function1[x_] := x, or you need to give the context explicitly. Either of these should work:

BeginPackage["Test1`"];
Begin["`Private`"];
Test1`Private`function1[x_] := x
End[];
EndPackage[];

Or:

BeginPackage["Test1`"];
Remove[function1]
Begin["`Private`"];
function1[x_] := x
End[];
EndPackage[];

If you wish to completely resent the contents of Test1` every time the package is run you might use Remove["Test1`*"].

  1. After running your Package code the first time Test1` is added to the $ContextPath.

  2. When you call Test1`function1[5] the symbol function1 is created in the context Test1`

  3. After calling BeginPackage["Test1`"] and Begin["`Private`"] the $ContextPath is: {"Test1`","System`"}

  4. When you use function1 in function1[x_] := x it is found in the $ContextPath and therefore it parses as Test1`function1.

To avoid this, you need to either remove the symbol Test1`function1 from the context path before defining function1[x_] := x, or you need to give the context explicitly. Either of these should work:

BeginPackage["Test1`"];
Begin["`Private`"];
Test1`Private`function1[x_] := x
End[];
EndPackage[];

Or:

BeginPackage["Test1`"];
Remove[function1]
Begin["`Private`"];
function1[x_] := x
End[];
EndPackage[];

If you wish to completely reset the contents of Test1` every time the package is run you might use Remove["Test1`*"].

deleted 2 characters in body
Source Link
Mr.Wizard
  • 273.1k
  • 34
  • 595
  • 1.4k
  1. After running your Package code the first time Test1` is added to the $ContextPath.

  2. When you call Test1`function1[5] the symbol function1 is created in the context Test1`

  3. After calling BeginPackage["Test1`"];BeginPackage["Test1`"] and Begin["`Private`"];Begin["`Private`"] the $ContextPath is: {"Test1`","System`"}

  4. When you use function1 in function1[x_] := x it is found in the $ContextPath and therefore it parses as Test1`function1.

To avoid this, you need to either remove the symbol Test1`function1 from the context path before defining function1[x_] := x, or you need to give the context explicitly. Either of these should work:

BeginPackage["Test1`"];
Begin["`Private`"];
Test1`Private`function1[x_] := x
End[];
EndPackage[];

Or:

BeginPackage["Test1`"];
Remove[function1]
Begin["`Private`"];
function1[x_] := x
End[];
EndPackage[];

If you wish to completely resent the contents of Test1` every time the package is run you might use Remove["Test1`*"].

  1. After running your Package code the first time Test1` is added to the $ContextPath.

  2. When you call Test1`function1[5] the symbol function1 is created in the context Test1`

  3. After calling BeginPackage["Test1`"]; and Begin["`Private`"]; the $ContextPath is: {"Test1`","System`"}

  4. When you use function1 in function1[x_] := x it is found in the $ContextPath and therefore it parses as Test1`function1.

To avoid this, you need to either remove the symbol Test1`function1 from the context path before defining function1[x_] := x, or you need to give the context explicitly. Either of these should work:

BeginPackage["Test1`"];
Begin["`Private`"];
Test1`Private`function1[x_] := x
End[];
EndPackage[];

Or:

BeginPackage["Test1`"];
Remove[function1]
Begin["`Private`"];
function1[x_] := x
End[];
EndPackage[];

If you wish to completely resent the contents of Test1` every time the package is run you might use Remove["Test1`*"].

  1. After running your Package code the first time Test1` is added to the $ContextPath.

  2. When you call Test1`function1[5] the symbol function1 is created in the context Test1`

  3. After calling BeginPackage["Test1`"] and Begin["`Private`"] the $ContextPath is: {"Test1`","System`"}

  4. When you use function1 in function1[x_] := x it is found in the $ContextPath and therefore it parses as Test1`function1.

To avoid this, you need to either remove the symbol Test1`function1 from the context path before defining function1[x_] := x, or you need to give the context explicitly. Either of these should work:

BeginPackage["Test1`"];
Begin["`Private`"];
Test1`Private`function1[x_] := x
End[];
EndPackage[];

Or:

BeginPackage["Test1`"];
Remove[function1]
Begin["`Private`"];
function1[x_] := x
End[];
EndPackage[];

If you wish to completely resent the contents of Test1` every time the package is run you might use Remove["Test1`*"].

Source Link
Mr.Wizard
  • 273.1k
  • 34
  • 595
  • 1.4k

  1. After running your Package code the first time Test1` is added to the $ContextPath.

  2. When you call Test1`function1[5] the symbol function1 is created in the context Test1`

  3. After calling BeginPackage["Test1`"]; and Begin["`Private`"]; the $ContextPath is: {"Test1`","System`"}

  4. When you use function1 in function1[x_] := x it is found in the $ContextPath and therefore it parses as Test1`function1.

To avoid this, you need to either remove the symbol Test1`function1 from the context path before defining function1[x_] := x, or you need to give the context explicitly. Either of these should work:

BeginPackage["Test1`"];
Begin["`Private`"];
Test1`Private`function1[x_] := x
End[];
EndPackage[];

Or:

BeginPackage["Test1`"];
Remove[function1]
Begin["`Private`"];
function1[x_] := x
End[];
EndPackage[];

If you wish to completely resent the contents of Test1` every time the package is run you might use Remove["Test1`*"].