diff options
| author | s-ol <s+removethis@s-ol.nu> | 2025-03-18 11:47:22 +0000 |
|---|---|---|
| committer | s-ol <s+removethis@s-ol.nu> | 2025-03-18 12:06:18 +0000 |
| commit | b6cbc69461dc054019f50f8971704f6ef9de63ab (patch) | |
| tree | d2b8942b780f668ccbe57b52dd8d65f61613e935 /docs/reference/05-2_structs.md | |
| parent | builtins: switch takes single array as value (diff) | |
| download | alive-wip.tar.gz alive-wip.zip | |
language: [array] and {struct} literalswip
Diffstat (limited to 'docs/reference/05-2_structs.md')
| -rw-r--r-- | docs/reference/05-2_structs.md | 10 |
1 files changed, 6 insertions, 4 deletions
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. |
