diff options
Diffstat (limited to 'cpp/060string.mu')
-rw-r--r-- | cpp/060string.mu | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/cpp/060string.mu b/cpp/060string.mu index a437c24f..85ff65b6 100644 --- a/cpp/060string.mu +++ b/cpp/060string.mu @@ -96,3 +96,20 @@ scenario string-equal-common-lengths-but-distinct [ 3 <- 0 # abc != abd ] ] + +# A new type to help incrementally construct strings. +container buffer [ + length:integer + data:address:array:character +] + +recipe init-buffer [ + default-space:address:space <- new location:type, 30:literal + result:address:buffer <- new buffer:type + len:address:integer <- get-address result:address:buffer/deref, length:offset + len:address:integer/deref <- copy 0:literal + s:address:address:array:character <- get-address result:address:buffer/deref, data:offset + capacity:integer <- next-ingredient + s:address:address:array:character/deref <- new character:type, capacity:integer + reply result:address:buffer +] |