open Reference;; let prs s = print_string s; print_newline();; let pri i = print_int i; print_newline();; let pr s = print_string (s^": ");; eval (fun memory -> let ref x = ref memory x in ref 0 (fun p -> pr "p"; pri (!p); p := 3; pr "p"; pri (!p); ref p (fun r -> pr "(r)"; pri (!(!r)); ref (!p) (fun q -> pr "q"; pri (!q); q := 2; pr "q"; pri (!q); pr "p"; pri (!p); p := (!q + !p); pr "p"; pri (!p); pr "q"; pri (!q); r := q; pr "(r)"; pri (!(!r)); ); pr "(r)"; pri (!(!r)); ); ref "foo" (fun s -> pr "s"; prs (!s) ); pr "p"; pri (!p) ) ) ;; print_int (eval (fun memory -> let ref x = ref memory x in ref 1 (fun r -> r := 3; !r + !r))) ;; print_newline();; print_string "End of examples";; print_newline();;