Imports
Supported languages generally have one or two of the following forms of imports:
    1.
    Importing specific items within a package
    2.
    Importing an entire package
We define a package here as either an external package or a local ("relative") file within the same project. So far, only importing specific items from relative files is supported.

Relative Imports

You can import specific constructs from other files using import local. It takes in three sections:
    Absolute directory path from the project root to file to import from, including the file's name
    Optionally, the use keyword followed by any runtime constructs (such as classes) to retrieve from the file
    Optionally, the types keyword followed by any interfaces to retrieve from the file
Languages that do not recognize interfaces, such as JavaScript, will ignore any types imports.
1
file start : MyProject Samples Sample
2
import local : MyProject Actors Actor use Actor
3
import local : MyProject Collections Storage use Storage types IStorage
4
import local : MyProject Definitions ActorDefinitions IAction types IAction
5
file end
Copied!
In C#:
1
using MyProject.Actors;
2
using MyProject.Collections;
3
using MyProject.Definitions.ActorDefinitions;
4
​
5
namespace MyProject.Samples
6
{
7
}
Copied!
In Python:
1
from ..actors.actor import Actor
2
from ..collections.storage import Storage
Copied!

Standalone Imports

​Standalone functions may become either a single class or collection of functions depending on the output language, so they must imported using a specialized import standalone functions command within an import local command's use section. It takes in the group name to import from and any number of items from the group.
1
file start : MyProject Samples Sample
2
import local : MyProject Utilities Strings use { import standalone functions : Strings IsPalindrome Repeat }
3
file end
Copied!
In C#:
1
using MyProject.Utilities;
2
​
3
namespace MyProject.Samples
4
{
5
}
Copied!
In Python:
1
from ...utilities.strings import is_palindrome repeat
Copied!

Absolute Imports

These are not supported yet.

Built-In Imports

You may have seen in previous examples that some languages prepend imports before their code. C#, for example, has using System; before any instance of Console.WriteLine. Budgie will keep track of system imports required for each native command.
Last modified 1yr ago