Hi,

I'm wondering if the execution order is defined during class
construction. For example:

let n = ref 0
let next () = incr n; !n
class foo = object
  val x = next ()
  val y = next ()
  val z = next ()
  method print = Printf.printf "%d %d %d\n" x y z
end

Will that always give x < y < z or could it initialize the values in
different order?

In my use case I want to parse the values from a stream and have
inheritance between classes.

class foo stream = object
  inherit base1 stream
  inherit base2 stream
  val x = parse_x stream
  val y = parse_y stream
end

Will that always execute in order? If the order is undefined then that would
make things more complex and require additional type definitions:

class foo stream =
  let base1_temp = parse_base1 stream in
  let base2_temp = parse_base2 stream in
  let x_temp = parse_x stream in
  let y_temp = parse_y stream
  in
    object
      inherit base1 base1_temp
      inherit base2 base2_temp
      val x = x_temp
      val y = y_temp
    end

MfG
        Goswin

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to