src/Pure/ML-Systems/single_assignment.ML
author wenzelm
Tue, 12 Mar 2013 16:47:24 +0100
changeset 51399 6ac3c29a300e
parent 35014 a725ff6ead26
permissions -rw-r--r--
discontinued "isabelle usedir" option -r (reset session path); simplified internal session identification: chapter / name; clarified chapter index (of sessions) vs. session index (of theories); discontinued "up" links, for improved modularity also wrt. partial browser_info (users can use "back" within the browser); removed obsolete session parent_path;

(*  Title:      Pure/ML-Systems/single_assignment.ML
    Author:     Makarius

References with single assignment.  Unsynchronized!
*)

signature SINGLE_ASSIGNMENT =
sig
  type 'a saref
  exception Locked
  val saref: unit -> 'a saref
  val savalue: 'a saref -> 'a option
  val saset: 'a saref * 'a -> unit
end;

structure SingleAssignment: SINGLE_ASSIGNMENT =
struct

exception Locked;

abstype 'a saref = SARef of 'a option ref
with

fun saref () = SARef (ref NONE);

fun savalue (SARef r) = ! r;

fun saset (SARef (r as ref NONE), x) = r := SOME x
  | saset _ = raise Locked;

end;

end;