Originally, C lacked the concept of slices, many reinventing
their own. An ABC slice is a pair of pointers: [head, term)
.
A slice is consumed by moving the head
towards term
. A slice
has four shades of const
:
$u8
;$u8c
;$cu8
can be edited, not consumed;$cu8c
can not be either consumed
or edited.A slice argument is always passed as a pointer, so these shades
are important. Also, $dup
is often used to create a duplicate
slice for consumption by the callee.
An ABC slice also serves as an iterator, e.g.
$u32 numbers;
...
$eat(numbers) {
printf("%u\n", **numbers);
}
Most often, a slice is a segment of an ABC buffer.