Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /sml/trunk/src/MLRISC/library/cache.sml
ViewVC logotype

Diff of /sml/trunk/src/MLRISC/library/cache.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 651, Thu Jun 1 18:34:03 2000 UTC revision 775, Fri Jan 12 01:17:51 2001 UTC
# Line 11  Line 11 
11    
12     val cache : ('a -> 'b) -> 'a -> 'b cache     val cache : ('a -> 'b) -> 'a -> 'b cache
13     val flush : 'a cache -> unit     val flush : 'a cache -> unit
14     val !!    : 'a cache -> 'a     val !     : 'a cache -> 'a
15       val :=    : 'a cache * 'a -> unit
16    
17  end  end
18    
# Line 22  Line 23 
23    
24     fun cache f x = (ref NONE, fn _ => f x)     fun cache f x = (ref NONE, fn _ => f x)
25    
26     fun flush (x as ref(SOME _),_) = x := NONE     fun flush (x,_) = x := NONE
      | flush (x,_) = ()  
27    
28     fun !! (r as ref NONE,f)    = let val x = f() in r := SOME x; x end     fun ! (r as ref NONE,f)    = let val x = f() in r := SOME x; x end
29       | !! (r as ref(SOME x),f) = x       | ! (r as ref(SOME x),f) = x
30    
31       val op := = fn((r, _),x) => r := SOME x
32    
33  end  end
34    

Legend:
Removed from v.651  
changed lines
  Added in v.775

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0