Skip to content

Commit 0805cea

Browse files
authored
Clarify structs
Fixes #633.
1 parent 9e59d76 commit 0805cea

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

infra.bs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1773,17 +1773,29 @@ a <a>map</a> |map|, with a less than algorithm |lessThanAlgo|, is to create a ne
17731773

17741774
<p>A <dfn export>struct</dfn> is a specification type consisting of a finite set of
17751775
<dfn export for=struct,tuple lt=item>items</dfn>, each of which has a unique and immutable
1776-
<dfn export for=struct,tuple>name</dfn>.
1776+
<dfn export for=struct,tuple>name</dfn>. An <a for=struct>item</a> holds a value of a defined type.
17771777

1778+
<div class=example id=example-struct>
1779+
<p>An <dfn ignore>email</dfn> is an example <a>struct</a> consisting of a
1780+
<dfn ignore>local part</dfn> (a string) and a <dfn ignore>host</dfn> (a <a for=/>host</a>).
1781+
1782+
<p>A nonsense algorithm might use this definition as follows:
1783+
1784+
<ol>
1785+
<li>Let <var ignore>email</var> be an email whose local part is "<code>hostmaster</code>" and host
1786+
is <code>infra.example</code>.
1787+
<li>&hellip;
1788+
</ol>
1789+
</div>
17781790

17791791
<h4 id=tuples>Tuples</h4>
17801792

1781-
<p>A <dfn export>tuple</dfn> is a <a>struct</a> with a defined order. For notational convenience, a
1782-
literal syntax can be used to express <a>tuples</a>, by surrounding the tuple with parenthesis and
1783-
separating its <a for=tuple>items</a> with a comma. To use this notation, the <a for=tuple>names</a>
1784-
need to be clear from context. This can be done by preceding the first instance with the name given
1785-
to the <a>tuple</a>. An indexing syntax can be used by providing a zero-based index into a
1786-
<a>tuple</a> inside square brackets. The index cannot be out-of-bounds.
1793+
<p>A <dfn export>tuple</dfn> is a <a>struct</a> whose <a for=struct>items</a> are ordered. For
1794+
notational convenience, a literal syntax can be used to express <a>tuples</a>, by surrounding the
1795+
tuple with parenthesis and separating its <a for=tuple>items</a> with a comma. To use this notation,
1796+
the <a for=tuple>names</a> need to be clear from context. This can be done by preceding the first
1797+
instance with the name given to the <a>tuple</a>. An indexing syntax can be used by providing a
1798+
zero-based index into a <a>tuple</a> inside square brackets. The index cannot be out-of-bounds.
17871799

17881800
<div class=example id=example-tuple>
17891801
<p>A <dfn ignore>status</dfn> is an example <a>tuple</a> consisting of a <dfn ignore>code</dfn> (a

0 commit comments

Comments
 (0)