From 0805ceaa349196e21f07efc41dd6543e52f42bb4 Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Wed, 14 Aug 2024 13:19:44 +0200 Subject: [PATCH] Clarify structs Fixes #633. --- infra.bs | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/infra.bs b/infra.bs index ae30c20..49eacf2 100644 --- a/infra.bs +++ b/infra.bs @@ -1773,17 +1773,29 @@ a map |map|, with a less than algorithm |lessThanAlgo|, is to create a ne

A struct is a specification type consisting of a finite set of items, each of which has a unique and immutable -name. +name. An item holds a value of a defined type. +

+

An email is an example struct consisting of a + local part (a string) and a host (a host). + +

A nonsense algorithm might use this definition as follows: + +

    +
  1. Let email be an email whose local part is "hostmaster" and host + is infra.example. +
  2. … +
+

Tuples

-

A tuple is a struct with a defined order. For notational convenience, a -literal syntax can be used to express tuples, by surrounding the tuple with parenthesis and -separating its items with a comma. To use this notation, the names -need to be clear from context. This can be done by preceding the first instance with the name given -to the tuple. An indexing syntax can be used by providing a zero-based index into a -tuple inside square brackets. The index cannot be out-of-bounds. +

A tuple is a struct whose items are ordered. For +notational convenience, a literal syntax can be used to express tuples, by surrounding the +tuple with parenthesis and separating its items with a comma. To use this notation, +the names need to be clear from context. This can be done by preceding the first +instance with the name given to the tuple. An indexing syntax can be used by providing a +zero-based index into a tuple inside square brackets. The index cannot be out-of-bounds.

A status is an example tuple consisting of a code (a