tur/rcchain
a collection of rc<A> the cycle collector can trace through.
Since: collections-cannot-hold-rc-values item 3
RcChain
(defstruct RcChain :move [A])
one link: an element and the rest of the chain.
Since: collections-cannot-hold-rc-values item 3
rcchain-nil
(rcchain-nil :)
the empty chain.
An empty chain (a null rc handle, which the walker skips). An ascription rather than an inline-C `return 0;` -- both lower identically, and the ascription keeps the module free of inline-C entirely, which is the point worth making about it: a collection the cycle collector can trace needs nothing below the language. (The inline-C form used to be actively worse: it emitted a base returning the int64 carrier, so every call site warned. Fixed and pinned by tests/fixtures/inline-c-rc-return-typed; the choice here is now taste.)
(rcchain-nil) ; => empty chain
Since: collections-cannot-hold-rc-values item 3
rcchain-empty?
(rcchain-empty? [^borrow c : rc<RcChain>] :)
1 if the chain has no links.
| c | the chain to test (borrowed) |
1 for the empty chain, 0 otherwise.
(rcchain-empty? (rcchain-nil)) ; => 1
Since: collections-cannot-hold-rc-values item 3
rcchain-cons
(rcchain-cons [A])
prepend an element to a chain.
| item | the element to prepend | |
| rest | the existing chain (or (rcchain-nil)) |
A new chain whose head is item.
(rcchain-cons (rc/clone x) (rcchain-nil))
Since: collections-cannot-hold-rc-values item 3
rcchain-head
(rcchain-head [A])
the element at the front of a chain.
| c | a non-empty chain (borrowed) |
The front element.
(rcchain-head (rcchain-cons (rc/clone x) (rcchain-nil)))
Since: collections-cannot-hold-rc-values item 3
rcchain-next
(rcchain-next [^borrow c : rc<RcChain>] :)
the rest of a chain, past its front link.
| c | a non-empty chain (borrowed) |
The remaining chain.
(rcchain-next (rcchain-cons (rc/clone x) (rcchain-nil))) ; => empty
Since: collections-cannot-hold-rc-values item 3