ocaml: Add alternate object-oriented programming style.
authorRichard W.M. Jones <rjones@redhat.com>
Sun, 3 Oct 2010 20:18:25 +0000 (21:18 +0100)
committerRichard W.M. Jones <rjones@redhat.com>
Sun, 3 Oct 2010 20:18:25 +0000 (21:18 +0100)
commit67636f721056d2f2250b0ff8acd981a0294536a9
tree6282c9c86f8af6823a22e436b2a95751f36b3b22
parent1a3324ea2b0f4a4e04f99c4efb5af1d4cc256731
ocaml: Add alternate object-oriented programming style.

In original style:

let () =
  let filename = Sys.argv.(1) in
  let g = Guestfs.create () in
  Guestfs.add_drive_ro g filename;
  Guestfs.launch g;
  let roots = Guestfs.inspect_os g in
  print_endline (Guestfs.inspect_get_product_name g roots.(0))

The same code in the new OO style:

let () =
  let filename = Sys.argv.(1) in
  let g = new Guestfs.guestfs in
  g#add_drive_ro filename;
  g#launch ();
  let roots = g#inspect_os () in
  print_endline (g#inspect_get_product_name roots.(0))
generator/generator_ocaml.ml
ocaml/t/guestfs_005_load.ml