#import / #include
Pull gate definitions from another .qubi file. #include is an exact alias. Pick whichever reads better. Both directives behave identically in the preprocessor and the editor.
#import my-gates.qubi #include shared/oracle.qubi
Filenames must end with .qubi and use only letters, digits, dots, hyphens, and underscores. Trailing // comments on the same line are allowed.
Where files are found
The simulator resolves imports in this order:
- Open editor tabs: any
.qubifile you have loaded in the Qubi Code Editor (matched case-insensitively by filename). - Library cache: files already fetched during this session.
- Server libraries folder:
/simulator/libraries/yourfile.qubion the host.
If the file does not exist, compilation stops with #import filename: file not found on that line. The circuit builder clears instead of showing a half-parsed mess. Fix the path or create the tab before expecting gates from the import.
Editor autocomplete
After you type #import or #include (note the space), the code editor suggests existing .qubi files from your open tabs. The current file is excluded so you do not import yourself. Pick a suggestion or keep typing to filter.
Namespacing
Gates from my-gates.qubi register as my-gates-GATENAME (filename without extension, lowercased, plus hyphen). If the library gate does not collide with an existing bare name, you can also invoke it without the prefix.
Limits and hygiene
- Import depth is capped at 20 nested files.
- Circular imports are rejected with a clear error.
- Imports expand during preprocess, do not put
#importinside agate { }body. - When syncing code → circuit, import lines are validated before preprocess so missing files fail fast.
#import innovation.qubi for standard gates, that include is ignored if present.