A reasonable configuration language
rcl-lang.org
configuration-language
json
1# Standard library
2
3The <abbr>RCL</abbr> standard library is a dict of values that is in scope by
4default under the name `std`. Most of the built-in functionality is not in this
5`std` dict, but in methods on the builtin types. See the next chapters for those.
6
7## empty_set
8
9```rcl
10std.empty_set: Set[Void]
11```
12
13An empty set. This constant exists, because without type annotations, `{}` is an
14empty dict rather than an empty set. This constant is the standard way to refer
15to an empty set.
16
17## format_json
18
19 std.format_json: (value: Any) -> String
20
21Format the value as json, in the same way that [`rcl evaluate --format=json`](rcl_evaluate.md)
22would, except without a maximum width, so the result contains no newlines.
23
24```rcl
25std.format_json({a = 1})
26// Evaluates to:
27"{\"a\": 1}"
28```
29
30## range
31
32 std.range: (lower: Number, upper: Number) -> List[Number]
33
34Return the range of integers `lower` through `upper`. The lower bound is
35inclusive and the upper bound is exclusive. When the lower bound is greater
36than the upper bound, `range` returns an empty list.
37
38```rcl
39std.range(3, 7)
40// Evaluates to:
41[3, 4, 5, 6]
42
43std.range(7, 3)
44// Evaluates to:
45[]
46```
47
48## read_file_utf8
49
50 std.read_file_utf8: (path: String) -> String
51
52Return the contents of the file at the given path. Paths are treated the same
53as [for imports](imports.md#import-location), and are subject to the same
54[sandbox restrictions](rcl_evaluate.md#-sandbox-mode). The file must contain
55valid <abbr>UTF-8</abbr> text without byte order mark.