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=1.4 required=5.0 tests=SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id A1D35BC6B for ; Sat, 11 Aug 2007 19:56:17 +0200 (CEST) Received: from an-out-0708.google.com (an-out-0708.google.com [209.85.132.246]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l7BHuGS2007085 for ; Sat, 11 Aug 2007 19:56:17 +0200 Received: by an-out-0708.google.com with SMTP id b15so239915ana for ; Sat, 11 Aug 2007 10:56:16 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=HV5mPRw6HTdYT5o5fz58HVbwv6oTmJYe88epMOpN1F+jTJPpxjrgeC8PCR7CPGyC1nRh6VG+G+/YOBfuulwP3l3xM5XIbA3fbT5fPQ4/57x4XsFtkuO7Q/qYfDATbeTVpbWmcyxTp0ngsUsXrO/O3/XhLxH5Zf8QZ5HrFlJYMWM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=nvmZFtQETweEA2OAlrjoHFcdYG5ihubJEJtlRICdAB9xh4MfBSWGdI8RvFeINkgAp0GPfaHBIQ+Q9353xr5/W/XihWmUpps+E2pgTDJCGHQeytB2fSgul72x574GwJODp3VLxWwQ3Qe2K1uQUz86RYYI0hQes3ya55F9Xt85QAQ= Received: by 10.100.139.12 with SMTP id m12mr3985169and.1186854976106; Sat, 11 Aug 2007 10:56:16 -0700 (PDT) Received: by 10.100.189.1 with HTTP; Sat, 11 Aug 2007 10:56:16 -0700 (PDT) Message-ID: <6806cf750708111056v19107705p288e0b0bb152ef63@mail.gmail.com> Date: Sat, 11 Aug 2007 13:56:16 -0400 From: "Jeff Meister" To: caml-list@yquem.inria.fr Subject: Order of evaluation when constructing record values MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-j-chkmail-Score: MSGID : 46BDF840.000 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 46BDF840.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; stdin:01 ocaml:01 forgiveness:98 ints:01 int:01 int:01 let:03 let:03 constructing:04 constructing:04 pedantic:05 i'm:09 curious:09 evaluation:09 evaluation:09 I ask for forgiveness in advance for this silly pedantic question. I think my question is best illustrated with an example. Say I have this simple record type for holding a date: type date = { year : int; month : int; day : int; } Now, I want to read the year/month/day values from stdin, and I know they will appear in that order. So I do the following: let today = { year = read_int (); month = read_int (); day = read_int (); } For this to work, I need the ints to be read in the order given, or I could end up with a day of 2007 and a year of 11. Is there any guarantee that OCaml will follow that order of evaluation when constructing the record? Or do I have to force it with let-bindings like this: let today = let y = read_int () in let m = read_int () in let d = read_int () in { year = y; month = m; day = d; } Of course, it's not that big a deal for me to just use the let-binding method, but I'm curious, and it might make my code look nicer if I can rely on order of evaluation.