Imports
Import Statements
There are two different types of modules that can be imported into an Aura source file. The first are standard library modules, which always begin with aura
.
For example,
will import the standard library's io
package.
The second type of module that can be imported is modules located on the local file system in the same Aura project. These modules are imported via their path within the project.
For example, consider the following project structure:
The import path of local imports begin after the src
directory and goes to the imported file's directory. Therefore, main.aura
can import common.aura
with the following statement:
Import Aliases
When importing modules, they can be aliased using the as
keyword. For example:
The as
keyword can be used when importing both standard library and local modules. Once an imported module has an alias, the alias is used as the module's name for the entire source file. For example, once the io
package has been aliased with stdlib_io
, the programmer will call public functions in the io
package like so:
Multiple Imports
When importing multiple modules, the programmer may streamline the import statements by collecting the imported modules together with one import
keyword.
Import Scopes
Imports are scoped to the entire Aura source file, and must be included at the top of the file before any other declarations.