Skip to content

Commit

Permalink
doc: more text about Strings
Browse files Browse the repository at this point in the history
  • Loading branch information
david-christiansen committed Jul 17, 2024
1 parent 93af241 commit b89f3e4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions Manual/BuiltInTypes/String.lean
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ The fact that strings are internally represented as UTF-8-encoded byte arrays is
{include 0 Manual.BuiltInTypes.String.Logical}

# Run-Time Representation
%%%
tag := "string-runtime"
%%%

:::figure "Memory layout of strings" (name := "stringffi")
![Memory layout of strings](/static/figures/string.svg)
Expand Down Expand Up @@ -239,8 +242,9 @@ This is because they must implement the conversions between lists of characters
tag := "string-iterators"
%%%

Fundamentally, a string iterator is a pair of a string and a valid position in the string.

Fundamentally, a {name}`String.Iterator` is a pair of a string and a valid position in the string.
Iterators provide functions for getting the current character ({name String.Iterator.curr}`curr`), replacing the current character ({name String.Iterator.setCurr}`setCurr`), checking whether the iterator can move to the left or the right ({name String.Iterator.hasPrev}`hasPrev` and {name String.Iterator.hasNext}`hasNext`, respectively), and moving the iterator ({name String.Iterator.prev}`prev` and {name String.Iterator.next}`next`, respectively).
Clients are responsible for checking whether they've reached the beginning or end of the string; otherwise, the iterator ensures that its position always points at a character.

{docstring String.Iterator}

Expand Down
2 changes: 1 addition & 1 deletion Manual/BuiltInTypes/String/FFI.lean
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ typedef struct {
char m_data[0];
} lean_string_object;
```
TODO xref to runtime representation above
The representation of strings in C. See {ref "string-runtime"}[the description of run-time {name}`String`s] for more details.
:::

:::ffi "lean_is_string"
Expand Down

0 comments on commit b89f3e4

Please sign in to comment.