Cursors

pub interface Steps {
  type Item;
  operator next(self: Self) -> Self.Item?;
}

A type a for steps and next(x) takes one item from: it declares operator next, which answers its item or null at the end. A generic over a cursor bounds on it:

loft fn firsts<C: Steps>(c: C) -> iterator<C.Item> { for x in c { yield x; } }

**Any source a for walks becomes a cursor with as iterator<T>** — a vector, a slice, a range, a plain enum, a text (iterator<character>), a sorted, index, hash, spatial or trie — and gives the same items in the same order. A cursor is one place every holder shares: next(it) takes one item, peek(it) answers the next item and leaves it there, and a for x in it goes on from where next left it. What else a cursor answers is written in its type: iterator<T[#index]> (it#index, the position of the item last taken), [#count] (it#count, items taken so far), [#remove] (it#remove removes the item last taken from the collection), [#last] (it#last in a loop over it), and a parameter c: iterator<T[#break]> may end its caller's loop over c with c#break.

loft v = [10, 20, 30]; it = v as iterator<integer[#index]>; first = next(it); // 10, it#index is 0 ahead = peek(it); // 20, still in the cursor for x in it { … } // 20, then 30