大域変数で,入力されたシンボルの検索のための,$Contextより前のコンテキストのリストを与える.
$ContextPath
大域変数で,入力されたシンボルの検索のための,$Contextより前のコンテキストのリストを与える.
詳細
- それぞれのコンテキストは"name`"の形式の列で指定される.
- $ContextPathの要素は特定のシンボルを含むコンテキストの検索のためにテストされる.
- $ContextPathは,BeginPackageとEndPackageによって変更される.
- $ContextPathは,多くのオペレーティングシステムのファイルの「検索パス」と対応するWolfram言語のシンボルである.
例題
すべて開く すべて閉じる例 (2)
$ContextPathシンボルIntegrateは"System`"コンテキストにあるので見付かる:
Context[Integrate]指定された名前のシンボルが$ContextPath中のどのコンテキストにも見付からない場合は,そのシンボルが作られる:
On[General::newsym]xこのシンボルは,$Contextが与えるコンテキスト中に作られる:
Context[x] === $ContextOff[General::newsym]スコープ (2)
$ContextPathは,常に文字列のリストでなければならない:
$ContextPath = "System`"$ContextPath = {"System`"}$ContextPathは,単純なコンテキストと複雑なコンテキストの両方を含むことができる:
$ContextPath = {"simpleContext`", "compound`context`", "System`"}アプリケーション (1)
コンテキストパスにDeveloper`コンテキストを加える:
$ContextPath = Prepend[$ContextPath, "Developer`"];PackedArrayFormは直接使えるようになったDeveloper`コンテキストにあるコマンドである:
PackedArrayForm[Table[Range[i], {i, 5}]]$ContextPath = Rest[$ContextPath];特性と関係 (6)
$ContextPath上のシンボルは,$Context中の同じ名前のシンボルの前に見付けられる:
$Context = "MyContext`";MyContext`Grad = 5;{Grad, MyContext`Grad}System`Gradは,"System`"がデフォルトで$ContextPathの一員であるので見付かる:
Context[Grad]MemberQ[$ContextPath, "System`"]$ContextPathのコンテキストが順に検索される:
cont1`x = 5;
cont2`x = 7;
$ContextPath = {"cont1`", "cont2`", "System`"};
x"cont1`"と"cont2`"の順番を変えると,どのxが見付けられるかが変わる:
$ContextPath = {"cont2`", "cont1`", "System`"};
x入力シンボルにコンテキストマーカー(`)が含まれていると,$ContextPathは無視される:
$ContextPath = {"outer`", "System`"};
$Context = "outer`inner`";
outer`inner`x = 5xしかし,inner`xがパス上の"outer`"に追加されてouter`inner`xを形成することはない:
inner`xBeginPackageは"System`"とパッケージのコンテキスト構成するために$ContextPathを変える:
$ContextPath = {"System`", "Global`"}BeginPackage["PackageContext`"];
$ContextPathEndPackageは,パッケージのコンテキストを先頭に追加して$ContextPathの前の値を回復する:
EndPackage[];
$ContextPathBeginは$ContextPathの値を変えない:
$ContextPath = {"System`", "Global`"}Begin["NewContext`"];
$ContextPathEndも変えない:
End[];
$ContextPathアクティブなコンテキストエイリアスは$ContextPathに加えられない:
$ContextAliases["abc`"] = "NewContext`";
AppendTo[$ContextPath, "abc`"];
$ContextPathテクニカルノート
-
▪
- コンテキスト ▪
- コンテキストとパッケージ ▪
- パッケージ
関連するガイド
関連するワークフロー
- それぞれのノートブックに個々のコンテキストを自動的に使う ▪
- シンボル名のシャドーイングに対処する
履歴
1988 で導入 (1.0) | 2007 で更新 (6.0)
テキスト
Wolfram Research (1988), $ContextPath, Wolfram言語関数, https://reference.wolfram.com/language/ref/$ContextPath.html (2007年に更新).
CMS
Wolfram Language. 1988. "$ContextPath." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2007. https://reference.wolfram.com/language/ref/$ContextPath.html.
APA
Wolfram Language. (1988). $ContextPath. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/$ContextPath.html
BibTeX
@misc{reference.wolfram_2026_$contextpath, author="Wolfram Research", title="{$ContextPath}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/$ContextPath.html}", note=[Accessed: 08-September-2026]}
BibLaTeX
@online{reference.wolfram_2026_$contextpath, organization={Wolfram Research}, title={$ContextPath}, year={2007}, url={https://reference.wolfram.com/language/ref/$ContextPath.html}, note=[Accessed: 08-September-2026]}