graphix-stdlib 0.3.1

A dataflow language for UIs and network programming, standard library
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# Lexical Closures

Functions can reference variables outside of their definition. These variables
are captured by the function definition, and remain valid no matter where the
closure is called. For example,

```graphix
let f = {
  let v = cast<i64>(net::subscribe("/local/foo")$)$;
  |n| v + n
};
f(2)
```

`f` captures `v` and can use it even when it is called from a scope where `v`
isn't visible. Closures allow functions to encapsulate data, just like an object
in OOP.