问题描述
我的 Julia REPL 帮助为 LOAD_PATH 提供了以下内容:
帮助?>加载路径搜索:LOAD_PATH加载路径用于使用和导入语句的路径数组,以便在以下情况下用作项目环境或包目录加载代码.请参阅代码加载.
这是我在提示符下对 LOAD_PATH 的输出:
朱莉娅>LOAD_PATH # 下面的输出是什么?三元素数组{String,1}:@"@v#.#"@stdlib"
上面显示的 LOAD_PATH 输出看起来很奇怪.
有什么建议吗?
你看到的是 DEFAULT_LOAD_PATH
.
让我引用源中相关部分的评论代码:
## LOAD_PATH, HOME_PROJECT &活动项目### JULIA_LOAD_PATH: 在 `:` 上拆分(或 Windows 上的 `;`)# 第一个空条目被 DEFAULT_LOAD_PATH 替换,其余的被跳过# 以 `@` 开头的条目是命名环境:# - 命名环境中的前三个 `#` 被替换为版本号# - `@stdlib` 是标准库的特殊名称,并扩展到其路径
换句话说,
"@"
:用于加载相对于当前路径的东西(此处不完全确定,请参阅下面的更新)"@v#.#"
:将成为v1.0
环境的路径(假设您使用的是 1.0)."@stdlib"
:将成为标准库的路径
这可能应该在某处的 Pkg 文档中更准确地解释.介意在那里提交问题?(更新:见 https://github.com/JuliaLang/Pkg.jl/issues/第757章 更新: 可以使用 My Julia REPL Help provides the following for LOAD_PATH: Here is my output for LOAD_PATH at the prompt: The output shown above for LOAD_PATH seems strange. Any suggestions? What you see there is the Let me cite comments from the relevant section of the source code: In other words, This should probably be explained more precisely in the Pkg docs somewhere. Mind filing an issue over there? (UPDATE: See https://github.com/JuliaLang/Pkg.jl/issues/757) UPDATE: One can play around with the method 这篇关于在我的 Julia 1.0.0 REPL 中,LOAD_PATH 返回意外结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!Base.load_path_expand(a::AbstractString)
方法来看看最终会变成什么:朱莉娅>Base.load_path_expand.(LOAD_PATH.*"/test")三元素数组{String,1}:\test\Project.toml""C:\Users\carsten\.julia\environments\v1.0\test\Project.toml""C:\Users\carsten\.julia\environments\stdlib\test\Project.toml"
help?> LOAD_PATH
search: LOAD_PATH
LOAD_PATH
An array of paths for using and import statements to consdier as project environments or package directories when
loading code. See Code Loading.
julia> LOAD_PATH # What is the output below?
3-element Array{String,1}:
"@"
"@v#.#"
"@stdlib"
DEFAULT_LOAD_PATH
.## LOAD_PATH, HOME_PROJECT & ACTIVE_PROJECT ##
# JULIA_LOAD_PATH: split on `:` (or `;` on Windows)
# first empty entry is replaced with DEFAULT_LOAD_PATH, the rest are skipped
# entries starting with `@` are named environments:
# - the first three `#`s in a named environment are replaced with version numbers
# - `@stdlib` is a special name for the standard library and expands to its path
"@"
: is for loading things relative to the current path (not completely sure here, see update below)"@v#.#"
: will become the path to the v1.0
environment (assuming you are on 1.0)."@stdlib"
: will become the path to the stdlibsBase.load_path_expand(a::AbstractString)
to see what things become eventually:julia> Base.load_path_expand.(LOAD_PATH.*"/test")
3-element Array{String,1}:
"\test\Project.toml"
"C:\Users\carsten\.julia\environments\v1.0\test\Project.toml"
"C:\Users\carsten\.julia\environments\stdlib\test\Project.toml"