Glossary¶
Many concepts are universal across formats and languages, but are known by various names nonetheless. RCL adopts the following terminology.
Comprehension¶
A list, dict, or set comprehension is a way to construct a collection by iterating an existing collection. It is related to the idea of a for loop in imperative languages.
Dictionary¶
A dictionary, or dict for short, is a collection of key-value pairs where the keys are unique. A dict is called object in json, dict in Python, attrset in Nix, table in Lua, and associative array or map in many other languages.
In most places, using a dict in RCL looks the same as using a type with statically defined fields in other languages. In this sense, dicts also act as the analog of a struct or record in statically typed languages.
Function¶
Functions in RCL are anonymous: function values have no inherent name, but like any other value they can be bound to a name with a let binding. Functions are closures: they can capture values defined outside of the function body. Such functions are sometimes called lambda functions or lambdas in other languages.
If-else expression¶
Like everything in RCL, if-else is an expression, not control flow for statements. Some languages have a ternary operator that plays the same role. For example, cond ? x : y
in C, or x if cond else y
in Python, would be written if cond: x else: y
in RCL.
List¶
A list is an ordered collection of values, not necessarily unique. A list is called array in json.
Set¶
A set is a collection of values where each value occurs at most once.