8.3 Module Paths🔗ℹ
A module path is a reference to a module, as used with
import or as the language module path after ~lang
in a module form. It can be any of several forms.
A string
module path is a relative path using Unix-style
conventions:
/ is the path separator,
.. refers to
the parent directory, and
. refers to the same directory. The
string must not start or end with a path separator.
The path is relative to the enclosing file, if any, or it is relative to
the current directory.
Module Basics shows examples using relative paths.
|
|
|
collection_module_path | = | | | | | id / collection_module_path |
|
|
A
module path that is an identifier or
/-separated sequence of identifiers refers to an
installed library. The identifiers are constrained to contain only ASCII
letters, ASCII numbers,
+,
-, and
_. The
identifiers in such a collection path refer to
collections and
subcollections, instead of directories and subdirectories.
An example of this form is rhombus/measure. It refers
to the module whose source is the "measure.rhm" file in the
"rhombus" collection, which is installed as part of Rhombus.
The ".rhm" suffix is added automatically.
A
lib path is like an identifier path, but expressed as
a string instead of
/-separated identifiers. A
rel_string can end with a file suffix, in which case
".rhm" is not automatically added. If
rel_string does not contain
/, then
"/main.rhm" is appended to the string when forming the module
file path.
To refer to a Racket module, use a lib path with a
".rkt" suffix.
A
file path refers to a file, where
string is a relative or absolute path using the current
platform’s conventions. This form is not portable, and it should
not be used when a plain, portable string suffices.
A path with
! refers to the
submodule named
id of the module referenced by
module_path. Multiple uses of
! can be
chained to reach more deeply nested submodules.
The
self module path form
can be used only with
! to refer to a
submodule.
The form
self!id refers to a
submodule named
id of the enclosing module.
Additional uses of
! refer to more deeply nested
submodules within that one. In an interactive context such as a
REPL,
self!id refers to a module
declared interactively with name
id.
The form parent refers to the parent of an enclosing
submodule. A parent form may be followed by
!id to access a sibling submodule.
Additional ! operators immediately after
parent! reach further up the enclosing-module chain.
A prefix
. refers to an import prefix or a namespace
id in the enclosing environment, not to a separate
module. An infix
. refers to an exported
id (or operator
op) provided by a
module_path. When the last
id in a
dotted sequence is not itself a namespace, the dotted form is a
shorthand for exposing just that binding from
module_path.