Luk: Lua Konfig Language
Luk is a config language written in Lua... actually it
is lua, just with
different globals!
Most of luk's globals come from ds.dload. In addition to those globals, Luk
provides an (overrideable) import'name' function which can import other Luk
files (by path).
Usage:
local flowers = import'path/to/flowers.luk'
-- Do normal lua stuff.
local count = {}
for _, flower in pairs(flowers) do
count[flower.kind] = (count[flower.kind] or 0) + 1
end
return {
name = 'flower metrics',
kind_count = count,
}
Each luk module runs in it's own hermetic environment - that means it cannot
access globals from other modules, though it can of course see the table they
return.
Note that in the future, luk will likely force all values returned by a luk
module to also be immutable, meaning you won't be able to change them.
luk: lua config language.
Types: Table Luk
Functions
- fn value(v)
Convert value to luk-value. This is mostly used internally,
but feel free to use it as well.
A normal table except if you set
__call it will make
the table callable (since luk doesn't support setmetatable).
In addition, this will be frozen (made immutable) after being returned from
a luk module.
Usage:
Luk{}:import'path/to/file.luk'
The luk loader. Allows (recursively) importing a luk
module. Keeps a cache of already imported paths files.
Fields:
- imported
table of ipath -> imported luk
- imports
table of ipath to its imports for dependency analysis.
- pathFn =ds.iden
a function that given a non-relative import path
returns the path to the file to import.
- envMeta =ds.load.ENV
- cycle
used to detect cycles
Methods
- fn:resolve(path, wd) -> /abs/path
Resolve the path into the abspath.
- fn:import(path, wd) -> lukMod?, ds.Error?
Recursively import the luk file at path.
Each luk file has a sandboxed global environment.