src/Pure/Concurrent/single_assignment_sequential.ML
author wenzelm
Sat, 23 May 2015 17:19:37 +0200
changeset 60299 5ae2a2e74c93
parent 35014 a725ff6ead26
permissions -rw-r--r--
clarified NEWS: document_files are officially required since Isabelle2014, but the absence was tolerated as legacy feature;

(*  Title:      Pure/Concurrent/single_assignment_sequential.ML
    Author:     Makarius

Single-assignment variables (sequential version).
*)

structure Single_Assignment: SINGLE_ASSIGNMENT =
struct

abstype 'a var = Var of 'a SingleAssignment.saref
with

fun var _ = Var (SingleAssignment.saref ());

fun peek (Var var) = SingleAssignment.savalue var;

fun await v =
  (case peek v of
    SOME x => x
  | NONE => Thread.unavailable ());

fun assign (v as Var var) x =
  (case peek v of
    SOME _ => raise Fail "Duplicate assignment to variable"
  | NONE => SingleAssignment.saset (var, x));

end;

end;