comparison caching-tests/test.ur @ 2278:b7615e0ac4b0

Fix bug in and clean up free path code.
author Ziv Scully <ziv@mit.edu>
date Tue, 10 Nov 2015 12:35:00 -0500
parents c05f9a5e0f0f
children f8903af753ff
comparison
equal deleted inserted replaced
2277:6bce459ca581 2278:b7615e0ac4b0
3 fun cache id = 3 fun cache id =
4 res <- oneOrNoRows (SELECT tab.Val 4 res <- oneOrNoRows (SELECT tab.Val
5 FROM tab 5 FROM tab
6 WHERE tab.Id = {[id]}); 6 WHERE tab.Id = {[id]});
7 return <xml><body> 7 return <xml><body>
8 (* Reading {[id]}. *) 8 cache
9 {case res of 9 {case res of
10 None => <xml>?</xml> 10 None => <xml>?</xml>
11 | Some row => <xml>{[row.Tab.Val]}</xml>} 11 | Some row => <xml>{[row.Tab.Val]}</xml>}
12 </body></xml> 12 </body></xml>
13 13
14 (* fun sillyRecursive {Id = id, FooBar = fooBar} = *) 14 fun sillyRecursive {Id = id : int, FooBar = fooBar} =
15 (* if fooBar <= 0 *) 15 if fooBar <= 0
16 (* then 0 *) 16 then 0
17 (* else 1 + sillyRecursive {Id = id, FooBar = fooBar - 1} *) 17 else 1 + sillyRecursive {Id = id, FooBar = fooBar - 1}
18 18
19 fun cacheR (r : {Id : int, FooBar : int}) = 19 fun cacheR (r : {Id : int, FooBar : int}) =
20 res <- oneOrNoRows (SELECT tab.Val 20 res <- oneOrNoRows (SELECT tab.Val
21 FROM tab 21 FROM tab
22 WHERE tab.Id = {[r.Id]}); 22 WHERE tab.Id = {[r.Id]});
23 return <xml><body> 23 return <xml><body>
24 (* Reading {[r.Id]}. *) 24 cacheR {[r.FooBar]}
25 {case res of 25 {case res of
26 None => <xml>?</xml> 26 None => <xml>?</xml>
27 | Some row => <xml>{[row.Tab.Val]}</xml>} 27 | Some row => <xml>{[row.Tab.Val]}</xml>}
28 </body></xml> 28 </body></xml>
29 29