package base

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Use Iteration to implement iteration functions that guard against mutation.

type 'a queue := 'a t
type t

A token representing state from the beginning of an iteration.

val start : _ queue -> t

Capture state at the start of iteration.

val assert_no_mutation_since_start : t -> _ queue -> unit

assert_no_mutation_since_start t queue raises if any mutation has happened to queue since t was created by start queue. Results are unspecified if you call assert_no_mutation_since_start with a different queue from the one passed to start.

Call assert_no_mutation_since_start after each step of an iteration loop, before checking if the queue is empty or advancing to the next element. This ensures these read operations are consistent with the queue's state at the start of iteration.

OCaml

Innovation. Community. Security.