aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authors-ol <s+removethis@s-ol.nu>2025-03-18 11:47:22 +0000
committers-ol <s+removethis@s-ol.nu>2025-03-18 12:06:18 +0000
commitb6cbc69461dc054019f50f8971704f6ef9de63ab (patch)
treed2b8942b780f668ccbe57b52dd8d65f61613e935 /docs
parentbuiltins: switch takes single array as value (diff)
downloadalive-wip.tar.gz
alive-wip.zip
language: [array] and {struct} literalswip
Diffstat (limited to 'docs')
-rw-r--r--docs/reference/05-1_arrays.md12
-rw-r--r--docs/reference/05-2_structs.md10
2 files changed, 13 insertions, 9 deletions
diff --git a/docs/reference/05-1_arrays.md b/docs/reference/05-1_arrays.md
index fdd26ff..19075f5 100644
--- a/docs/reference/05-1_arrays.md
+++ b/docs/reference/05-1_arrays.md
@@ -1,9 +1,11 @@
Arrays are composite types that contain a fixed number of values of the same
-type. Arrays values can be created using the [`(array …)`][:array:] builtin,
-which uses [Pure Op](04-2_pure-operators.html) semantics to construct an array
-from its parameters, all of which have to be of the same type.
+type. Arrays values can be created using square brackets `[1 2 3]` (which is
+syntactic sugar for the [`(mkarray …)`][:mkarray:] builtin).
- (trace (array 1 2 3))
+This uses [Pure Op](04-2_pure-operators.html) semantics to construct an array
+from several values, all of which have to be of the same type.
+
+ (trace [1 2 3])
```output
<num[3]= [1 2 3]>
```
@@ -11,4 +13,4 @@ from its parameters, all of which have to be of the same type.
The type notation `num[3]` designates an array of three numbers, whereas the
value notation `[1 2 3]` is used to show the array contents.
-The [array-][:array-/:] module provides *Op*s for working with arrays.
+The [array][:array/:] module provides *Op*s for working with arrays.
diff --git a/docs/reference/05-2_structs.md b/docs/reference/05-2_structs.md
index d3074c9..c9b234e 100644
--- a/docs/reference/05-2_structs.md
+++ b/docs/reference/05-2_structs.md
@@ -2,11 +2,13 @@ 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
+Struct values can be created using curly brackets `{"key" 3}` (which is
+syntactic sugar for the [`(mkstruct …)`][:mkstruct:] builtin).
+
+This 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'))
+ (trace {"a" 1 "b" 'hello world'})
```output
<{a: num b: str}= {a: 1 b: "hello world"}>
```
@@ -16,4 +18,4 @@ 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.
+The [struct][:struct/:] module provides *Op*s for working with arrays.