Each kaba source file is a module.
Given a source file source.kaba
with contents
var a: i32
class X
...
func f()
...
you can then import those symbols and use them from another source file (skip .kaba
):
use source.f # individually
use source.* # or all
f()
Or you can import the whole namespace:
use source
source.f()
If you have a tree of source files
base/
first.kaba
a/
second.kaba
b/
third.kaba
me.kaba
From within me.kaba
, import:
use first
use a.second
use third
🔥 Rule: files are automatically searched in the current directory and "several" of its parents (i.e. base/b/
then base/
).
🔥 Other directories need to be added with dots (base.a.second
) relative to the common parent.
Multiple modules in one directory can be treated as one unit, a package.
The directory must contain a module with the same name:
a/
a.kaba
other.kaba
Now a simple
import a
is enough. a.kaba
should export all relevant symbols...
🔥 The exact rules are still under development!
The kaba compiler provides several packages by default.
base.*
and math.*
are automatically imported.
Others include file management (os
), image loading (image
), networking (net
), graphical user interfaces (hui
), OpenGl (gl
) and Vulkan (vulkan
).