Syntax
Custom node definition (Experimental)

Custom Node Definition (Experimental)

Flow provides an experimental feature for defining custom nodes.

We have already shown how to express simple recursion, like factorial, in Flow. This feature can be used for more complex recursion.

> fib (@x ->) (-> @y) = @x -> if (@x == 0 || @x == 1) (then:-> 1 ->) (else:-> next ->) merge -> @y
> next (@x ->) (-> @y) = fib (@x - 1) + fib (@x - 2) -> @y
> :{
> @x'0 -> fib -> output
> @x'0 + 1 -> @x
> :}
1
1
2
3
5
8
13.

Defining a custom node adds it to the environment, making it callable throughout the session. Therefore, :{ :} is not required when calling it.

Currently, performance is poor, and execution can be quite slow.

At this stage, only functional custom nodes are supported. This means that the node only starts processing data when all inputs have received a value, and all outputs are only sent downstream once they are all ready within the custom node.

More flexible ways to define custom nodes are under consideration.