Commits

camlspotter committed 81dac83

update

Comments (0)

Files changed (4)

+.*\.(cm*|a|o|omc|out)$
+.*~$
+.*\.out\.ml$
+.*\.auto\.mli$
+
 test.exe: test.out.ml
     ocamlc -o test.exe polyrecord.cma test.out.ml
 
-.DEFAULT: test.out.cmo
+.DEFAULT: test.exe
 
+
-type +'a t 
+type 'a t  (** since it is mutable record, it must be invariant *)
 
 val create : (int * Obj.t) list -> 'a t
 val update : 'a t -> (int * Obj.t) list -> 'a t
-let f = {< x = 1; y = None >}
+let r = {< x = 1; y = None >}
 
-let g = {< f with x = 3 >}
-
-(* impos       let g = {< f with z = 3 >} *)
-
-let _ = f..x + 2
-
-let _ = g..y <- Some 3  (* all the fields are mutable *)
+let 3 = r..x + 2
 
 (* those records are just hashtbls, so streamable *)
-let _ = output_value stdout f
+let () = output_value stdout r; print_newline ()
 
+let r2 = {< r with x = 3 >} (* make a copy *)
+
+(* impos       let r2 = {< r with z = 3 >} *)
+
+let () = r2..y <- Some 3;;  (* all the fields are mutable *)
+
+(* impos: since it is a ref
+  let () = r2..y <- Some 3.0;;  (* all the fields are mutable *) 
+*)
+
+let () = Printf.printf "%d\n" (match r2..y with None -> -1 | Some v -> v)
+ 
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.