From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: weis Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id QAA17533 for caml-redistribution; Thu, 12 Aug 1999 16:42:26 +0200 (MET DST) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id OAA12492 for ; Thu, 12 Aug 1999 14:02:38 +0200 (MET DST) Received: from lri.lri.fr (lri.lri.fr [129.175.15.1]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id NAA19044 for ; Thu, 12 Aug 1999 13:23:01 +0200 (MET DST) Received: from pc89.lri.fr (pc89.lri.fr [129.175.8.108]) by lri.lri.fr (8.9.1a/8.9.1) with ESMTP id NAA13988; Thu, 12 Aug 1999 13:23:00 +0200 (MET DST) Received: by pc89.lri.fr (8.8.7/feuille) id NAA11427 ; Thu, 12 Aug 1999 13:22:59 +0200 X-Authentication-Warning: pc89.lri.fr: filliatr set sender to filliatr@pc89.lri.fr using -f From: Jean-Christophe Filliatre MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <14258.44691.363797.52662@pc89.lri.fr> Date: Thu, 12 Aug 1999 13:22:59 +0200 (MEST) To: John Skaller Cc: caml-list@inria.fr Subject: Re: Constructor/reference bug? In-Reply-To: <3.0.6.32.19990811180530.00985e40@mail.triode.net.au> References: <3.0.6.32.19990811180530.00985e40@mail.triode.net.au> X-Mailer: VM 6.49 under Emacs 20.3.1 Reply-To: Jean-Christophe.Filliatre@lri.fr (Jean-Christophe Filliatre) Content-Transfer-Encoding: 7bit Sender: weis > | COLON :: t -> CTRL !lineno :: f t > > The code doesn't work as I expected: every > CTRL value refers to the same lineno, the last one. > If I change the COLON line to read: That is only because the second argument is evaluated before the first one in a cons (::). Indeed, you can try ====================================================================== # print_int 1 :: print_int 2 :: [];; ====================================================================== and you will get ====================================================================== 21- : unit list = [(); ()] ====================================================================== It explains your problem. As you can read it in the ocaml reference manual, the order of evaluation of tuples elements in the not specified : ====================================================================== Products The expression expr1 ,..., exprn evaluates to the n-tuple of the values of expressions expr1 to exprn. The evaluation order for the subexpressions is not specified. Variants The expression ncconstr expr evaluates to the variant value whose constructor is ncconstr, and whose argument is the value of expr. ====================================================================== so your second code with a "let in" should be used. > | COLON :: t -> let x = !lineno in CTRL x :: f t Best regards, -- Jean-Christophe FILLIATRE mailto:Jean-Christophe.Filliatre@lri.fr http://www.lri.fr/~filliatr