signature HOLE structure Hole : HOLE
The Hole structure provides operations to create and inspect holes. A hole is a place-holder for an undetermined value, reminiscent of a "logic" variable in logic programming. A hole is very much like a promise, but is transparent in its type. Filling a hole globally replaces the hole with a value. Unlike a future, accessing a hole does not imply synchronization, but causes the exception Hole to be raised (this includes calls to Future.status). It is possible to extract a future from a hole, though.
The use of the Hole structure is strongly discouraged! For most tasks, Promise is the prefarable choice, as it is safer from a typing point of view and compatible with concurrent programming. Holes should be considered a low-level concept.
Imported implicitly.
signature HOLE = sig exception Hole val hole : unit -> 'a val future : 'a -> 'a val fill : 'a * 'a -> unit val fail : 'a * exn -> unit val isHole : 'a -> bool end
Raised on any attempt to access a hole, and on any attempt to pass a non-hole to any of the functions in this structure.
Creates a new hole and an associated future. Returns the hole.
Returns the future associated with the hole h. If h is not a hole, h is returned.
Replaces the hole h and its associated future with the value v. If v is the hole or its future itself, the exception Future.Cyclic is raised instead. If h is not a hole, Hole is raised.
Requests the exception ex, fails the future associated with the hole h with ex, and fills the hole with the same failed future. If h is not a hole, Hole is raised. Equivalent to
(Future.await ex; fill (h, spawn raise ex))
Returns true if v is a hole, false otherwise.