src/Pure/ML-Systems/unsynchronized.ML
author krauss
Wed, 05 May 2010 00:59:59 +0200
changeset 36664 6302f9ad7047
parent 32737 76fa673eee8b
child 38799 712cb964d113
permissions -rw-r--r--
repaired comments where SOMEthing went utterly wrong (cf. 2b04504fcb69)

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

Raw ML references as unsynchronized state variables.
*)

structure Unsynchronized =
struct

datatype ref = datatype ref;

val op := = op :=;
val ! = !;

fun set flag = (flag := true; true);
fun reset flag = (flag := false; false);
fun toggle flag = (flag := not (! flag); ! flag);

fun change r f = r := f (! r);
fun change_result r f = let val (x, y) = f (! r) in r := y; x end;

fun inc i = (i := ! i + (1: int); ! i);
fun dec i = (i := ! i - (1: int); ! i);

end;