From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id C50B6BBC4 for ; Fri, 3 Apr 2009 23:09:22 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkACAI8X1knZSMDdjmdsb2JhbACBUpRRAQEBAQkLCAkPBbgthA8G X-IronPort-AV: E=Sophos;i="4.38,431,1233529200"; d="scan'208";a="26987779" Received: from fmmailgate01.web.de ([217.72.192.221]) by mail1-smtp-roc.national.inria.fr with ESMTP; 03 Apr 2009 23:09:22 +0200 Received: from smtp05.web.de (fmsmtp05.dlan.cinetic.de [172.20.4.166]) by fmmailgate01.web.de (Postfix) with ESMTP id 0484AFF6275F for ; Fri, 3 Apr 2009 23:09:22 +0200 (CEST) Received: from [78.43.226.218] (helo=frosties.localdomain) by smtp05.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #277) id 1Lpqdd-0000Az-00 for caml-list@yquem.inria.fr; Fri, 03 Apr 2009 23:09:21 +0200 Received: from mrvn by frosties.localdomain with local (Exim 4.69) (envelope-from ) id 1Lpqdd-0006FB-AX for caml-list@yquem.inria.fr; Fri, 03 Apr 2009 23:09:21 +0200 From: Goswin von Brederlow To: caml-list@yquem.inria.fr Subject: Execution order in class construction Date: Fri, 03 Apr 2009 23:09:21 +0200 Message-ID: <87vdpligvy.fsf@frosties.localdomain> User-Agent: Gnus/5.110006 (No Gnus v0.6) XEmacs/21.4.21 (linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: goswin-v-b@web.de X-Sender: goswin-v-b@web.de X-Provags-ID: V01U2FsdGVkX19B4wfrCl7bWIT2R4otCvdyv4Ko44MG6Ri3sPta o7+keJL0jG4DElogArfJEUutHbpSlXCy8NMcHOyJfRXNcIclSw KMdUrb11Q= X-Spam: no; 0.00; foo:01 val:01 val:01 printf:01 printf:01 foo:01 mfg:98 inherit:01 inherit:01 undefined:01 defined:02 parse:02 parse:02 inheritance:03 let:03 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