Core Concepts
This section contains a brief explanation of core concepts.
The main concepts that you need to know are:
-
Attributes are values, it can be float, integer, boolean, strings, or list of attributes, or a map of attributes (key=value),
-
Nodes are points in the network, they can have attributes, input nodes and an output node,
-
Network is a collection of nodes, network can also have attributes, Network used in the NADI System can have only one outlet, so a ‘ROOT’ node is added if there are multiple outlet. And loading a network that is not a directed tree is undefined behaviour.
-
Expression is something that can be evaluated or executed, it consists of literal values (attributes), variables (node, network, env variables that could hold attributes), function calls, or a mathmatical or logical operation.
-
Functions in nadi are of 3 types, env functions are normal functions that take values and run, network functions take values and run on the network, while node functions run at each node (they also provide a way to subset which nodes to run it on).
-
Task is an execution body of the task system. It can be of env, network or node type. It can be conditional (If-Else) or loop (While) consisting of more tasks inside it. Task can assign values to the env/network/node attributes, or call mutable functions on the top level.
-
String Template: Some functions take string inputs that are interpreted dynamically to represent different strings based on variables.
-
Plugins provide the functions used by the nadi task system. There are internal plugins and external plugins. Internal plugins comes with the installation, while external plugins are loaded from dynamic libraries.
Keywords
Keyword | Description |
---|---|
node | the node task type, function or variable |
network/net | the network task type, function or variable |
env | the environment task type, function or variable |
exit | exit the program |
end | end the execution of tasks without exiting |
help | display help for functions |
inputs | get node variables or function output for input nodes of a node |
output | get node variable or function output for output node of a node |
nodes | get node variable or function output for all nodes in the network |
if | if statement for conditional task/expression |
else | else statement for conditional task/expression |
while | while statement for loop task |
in | binary operator to check if something is in another (list/string) |
match | binary operator to check patterns on string (regex) |
And here are some keywords reserved for future:
Keyword | Description |
---|---|
function/func | user defined functions |
map | map values in an array/attrmap to a function |
attrs | attributes of the env/node/network |
loop | loop task |
for | for loop task for looping through array/attrmap |
Symbols
Some special symbols and their functions are listed below:
.
dot accessor for variables, e.g.node.var
,node.var.another
, etc.,?
variable check (only used after a variable) e.g.node.var?
evaluates to atrue
orfalse
,()
,{}
,[]
brackets for functions/expressions, attrmaps and arrays,;
suppress current task output (only used at the end of a task),+
,-
,*
,/
, and//
are mathematical operators,&
,|
, and!
are logical operators,>
,<
,>=
,<=
, and==
are comparision operators,->
path operator (only used in node propagation, or network),=
is assignment operator,#
starts a comment,
There might be more functions of each symbol depending on the context.
Continue with the chapters for details on each concept. Or skip ahead to Learn by Examples if you want to jump into the examples.