aboutsummaryrefslogtreecommitdiffstats
path: root/docs/reference/05-2_structs.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/reference/05-2_structs.md')
-rw-r--r--docs/reference/05-2_structs.md16
1 files changed, 16 insertions, 0 deletions
diff --git a/docs/reference/05-2_structs.md b/docs/reference/05-2_structs.md
new file mode 100644
index 0000000..83181df
--- /dev/null
+++ b/docs/reference/05-2_structs.md
@@ -0,0 +1,16 @@
+Structs are composite types that contain values of different types associated
+with a set of string keys. The set of keys and their corresponding value types
+is fixed at *runtime*.
+
+Struct values can be created using the the [`(struct …)`][:struct:] builtin,
+which uses [Pure Op](04-2_pure-operators.html) semantics to construct a struct
+from its parameters. The keys have to be constants.
+
+ (trace (struct "a" 1 "b" 'hello world')) <{a: num b: str}= {a: 1 b: "hello world"}>
+
+The type notation `{a: num b: str}` designates a struct type with the key `a`
+mapping to a value of type `num` and the key `b` mapping to a value of type
+`str` respectively, whereas the value notation `{a: 1 b: "hello world"}` shows
+the struct contents.
+
+The [struct][:struct/:] module provides *Op*s for working with arrays.