How can you introduce a package, so that it is listed in $Packages, without adding it to $ContextPath?
Note that this question is concerned with defining a package when evaluating code, e.g. through evaluating a cell, rather than loading a package from a file.
This is useful if you want to add capabilities without introducing new "bare" symbols in any way -- they live in their own context and must be referenced through an explicit context, unless the user adds that context back to the context path.
Answer
Just using DeleteCases seems to work too:
BeginPackage["ChurchNumerals`"];
ZERO::usage = "ZERO is the Church encoding of zero";
ONE::usage = "ONE is the Church numeral encoding of the integer 1";
TWO::usage = "TWO is the Church numeral encoding of the integer 2";
Begin["`Private`"];
ZERO = Function[f, Function[n, n]];
ONE = Function[f, Function[n, f[n]]];
TWO = Function[f, Function[n, f[f[n]]]];
End[];
EndPackage[];
$ContextPath = DeleteCases[$ContextPath, "ChurchNumerals`"]
Comments
Post a Comment