CRITICAL force
authorhaftmann
Tue Nov 06 13:12:52 2007 +0100 (2007-11-06)
changeset 253102b928fb92f53
parent 25309 30142fd3babf
child 25311 aa750e3a581c
CRITICAL force
src/Pure/General/susp.ML
     1.1 --- a/src/Pure/General/susp.ML	Tue Nov 06 13:12:50 2007 +0100
     1.2 +++ b/src/Pure/General/susp.ML	Tue Nov 06 13:12:52 2007 +0100
     1.3 @@ -2,8 +2,7 @@
     1.4      ID:         $Id$
     1.5      Author:     Sebastian Skalberg and Florian Haftmann, TU Muenchen
     1.6  
     1.7 -Delayed evaluation. Supposed to be value oriented; may result in
     1.8 -multiple evaluations in a multi-threaded environment!
     1.9 +Delayed evaluation. Supposed to be value-oriented.
    1.10  *)
    1.11  
    1.12  signature SUSP =
    1.13 @@ -30,13 +29,18 @@
    1.14  fun delay f = ref (Delay f);
    1.15  
    1.16  fun force susp =
    1.17 -  (case ! susp of
    1.18 -    Value v => v
    1.19 -  | Delay f =>
    1.20 -      let
    1.21 -        val v = f ();
    1.22 -        val _ = susp := Value v;
    1.23 -      in v end);
    1.24 +  let
    1.25 +    fun forc () = case ! susp
    1.26 +     of Value v => v
    1.27 +      | Delay f =>
    1.28 +          let
    1.29 +            val v = f ();
    1.30 +            val _ = susp := Value v;
    1.31 +          in v end;
    1.32 +  in case ! susp
    1.33 +   of Value v => v
    1.34 +    | Delay _ => NAMED_CRITICAL "sups" forc
    1.35 +  end;
    1.36  
    1.37  fun peek susp =
    1.38    (case ! susp of