Skip to content

File Imports

Isaac Shelton edited this page Sep 13, 2023 · 3 revisions

File Imports

Files can be imported using the import keyword

import stdlib_component
import “local_file.adept”
import ‘local_file.adept’

Attempts to import an already imported file are ignored

Import Search Path

By default, Adept will look for files inside the local directory and the global import folder

See import search path for more information

Common Imports

Files can be imported by specifying the name of a file after the import keyword

// ---------------
// main.adept
// ---------------

import "greet.adept"

func main {
    greet("Isaac")
}
// ---------------
// greet.adept
// ---------------

import String
import terminal

func greet(name String) {
    print("Welcome " + name)
}

Standard Library Components

Standard library components can be imported without specifying a version by doing:

import String

Standard Library Folder

When looking for standard library component, only the standard library folder will be searched.

The default standard library folder is the version number of latest Adept release supported by the compiler (e.g. 2.5). You can see where it lives on your system by running adept --version which will include your Stblib Folder.

Platform:     	MacOS

Adept Build:	Adept 2.5 - Build Nov 24 2020 15:28:07 CDT
Adept Version:	2.5
Pkg Manager:	disabled

Import Folder:	"/Users/isaac/Projects/Adept/bin/import/"
Stblib Folder:	"/Users/isaac/Projects/Adept/bin/import/2.5"

The standard library folder can be changed either with --std= or pragma default_stdlib.

adept --std=2.3 main.adept
pragma default_stdlib ‘2.5-custom-stdlib’

See command line arguments and/or pragma default_stdlib for more information.

Clone this wiki locally