From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
To: goswin-v-b@web.de
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Execution order in class construction
Date: Mon, 06 Apr 2009 13:41:55 +0900 (JST) [thread overview]
Message-ID: <20090406.134155.147748336.garrigue@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <87vdpligvy.fsf@frosties.localdomain>
From: Goswin von Brederlow <goswin-v-b@web.de>
> 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?
This is not explicitly specified in the manual (but not explicitly
left unspecified either). The same thing seems to be true for
initializers too.
The current implementation keeps the definition order, and I don't see
why it should change, but if your code depends on such things it may
always be a good idea to put somewhere a bit of code that verifies
that the behaviour is correct.
Jacques Garrigue
next prev parent reply other threads:[~2009-04-06 4:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-03 21:09 Goswin von Brederlow
2009-04-06 4:41 ` Jacques Garrigue [this message]
2009-04-06 6:12 ` [Caml-list] " Goswin von Brederlow
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090406.134155.147748336.garrigue@math.nagoya-u.ac.jp \
--to=garrigue@math.nagoya-u.ac.jp \
--cc=caml-list@yquem.inria.fr \
--cc=goswin-v-b@web.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).