Inherited from v1.0.0

import / as keywords

import brings a module into the current file. as binds it to a local name. Together they look like import "name" as alias;. The Bangla forms are আমদানি and যেমন.

Syntax

import "<name>" as <alias>;

The string after import selects what to load. The identifier after as is the local name used for member access.

Standard library

import "io"     as io;
import "path"   as path;
import "web"    as web;
import "async"  as async;

var text = io.read_file(path.join(["docs", "intro.md"]));
print(text);

The standard library modules (io, path, web, request, async, template, sqlite, pg, mysql, mongo, crypto, json, regex, time, timers, math, random, log, dotenv, cli, test, …) ship with the runtime — no installation needed.

Packages installed via BPM

import "some-package" as pkg;
print(pkg.hello());

bpm install some-package drops the package into ./deps/some-package/, and the import resolver finds it there. The package's entry point is declared in its bnl.json ("main": "src/index.bnl").

Native plugins

Native modules — .dll / .so / .dylib shared libraries that implement bnl's C plugin contract — can be imported by direct path or installed via bpm and imported by name. Plugins use a single drop-in C header (bnl/plugin.h) and can be written in C, C++, Rust, Go, Zig, or any language with C FFI. See Plugin development for the full guide.

// Direct path (script next to the .dll):
import "./build/bin/mathx.dll" as m;

print(m.cube(3));      // calls native cube()
print(m.hypot(5, 12));

// Installed by bpm (resolved through deps/my-plugin/bnl.json):
import "my-plugin" as p;
print(p.greet("world"));

A native dep's bnl.json declares the shared library filename in its native field; the import resolver finds it the same way it finds pure-bnl deps.

Renaming

Use as to pick a shorter or more contextual name:

import "request" as req;
import "io"      as fs;        // call it whatever reads best in this file

req.get("https://example.com", function (err, resp) { /* ... */ });
fs.read_file("notes.txt");

Notes

  • The string after import is a literal — it cannot be a runtime expression. Imports are resolved statically.
  • Each import declares exactly one alias. There is no multi-name or wildcard import.
  • Imports are top-level. Don't put import inside a function or if block.

Bangla form

আমদানি "io"   যেমন io;
আমদানি "path" যেমন path;

চলক text = io.read_file(path.join(["docs", "intro.md"]));
print(text);