Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion mathics/builtin/directories/user_directories.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


class Path(Predefined):
"""
r"""
<url>:WMA link:https://reference.wolfram.com/language/ref/Path.html</url>

<dl>
Expand All @@ -23,6 +23,13 @@ class Path(Predefined):

>> $Path
= ...

'\$Path' used consulted in builtin functions <url>
:\$Get:
/doc/reference-of-built-in-symbols/inputoutput-files-and-filesystem/file-and-stream-operations/get/</url>, \
and <url>
:Needs:
/doc/reference-of-built-in-symbols/inputoutput-files-and-filesystem/filesystem-operations/needs/</url> to resolve filenames, and to resolve contexts to file names.
"""

attributes = A_NO_ATTRIBUTES
Expand Down
23 changes: 21 additions & 2 deletions mathics/builtin/files_io/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,28 @@ class Get(PrefixOperator):
= Cos[x] + I Sin[x]
S> DeleteFile[filename]

If the 'Path' is not fully qualified built-in variable <url>
:\$Path:
/doc/reference-of-built-in-symbols/directories-and-directory-operations/user-file-directories/$path/</url> is consulted.

'Get' can also load packages:
>> $ContextPath
= ...
S> << "VectorAnalysis`"
= ...

If a package is loaded variable <url>
:\$ContextPath:
/doc/reference-of-built-in-symbols/scoping-constructs/$contextpath/</url> is updated with the new package context name:
>> $ContextPath
= ...

See also <url>
:Needs:
/doc/reference-of-built-in-symbols/inputoutput-files-and-filesystem/filesystem-operations/needs/</url>.


## TODO: Requires EndPackage implemented
## 'Get' can also load packages:
## >> << "VectorAnalysis`"
"""

eval_error = Builtin.generic_argument_error
Expand Down
15 changes: 15 additions & 0 deletions mathics/builtin/files_io/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,21 @@ class Needs(Builtin):
</dl>

>> Needs["VectorAnalysis`"]

In contrast to <url>
:Get:
/doc/reference-of-built-in-symbols/inputoutput-files-and-filesystem/file-and-stream-operations/get/</url>, \
'Needs' only loads a package if it has not already been loaded.

Like 'Get', <url>
:\$ContextPath:
/doc/reference-of-built-in-symbols/scoping-constructs/$contextpath/</url> is updated \
when a new package context is added.

Builtin variable <url>
:\$Path:
/doc/reference-of-built-in-symbols/directories-and-directory-operations/user-file-directories/$path/</url> is used resolve the context to a file name.

"""

messages = {
Expand Down
11 changes: 11 additions & 0 deletions mathics/builtin/scoping.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,17 @@ class ContextPath_(Predefined):
## #> System`$ContextPath
## = {x`}
## #> $ContextPath = {"System`", "Global`"};

Functions <url>
:Needs:
/doc/reference-of-built-in-symbols/inputoutput-files-and-filesystem/filesystem-operations/needs/</url> and <url>
:Get:
/doc/reference-of-built-in-symbols/inputoutput-files-and-filesystem/file-and-stream-operations/get/</url>, \
add to '\$ContextPath' when a new context is added.

See also Builtin variable <url>
:\$Path:
/doc/reference-of-built-in-symbols/directories-and-directory-operations/user-file-directories/$path/</url>.
"""

messages = {"cxlist": "`1` is not a list of valid context names ending in `."}
Expand Down
Loading