From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 75BDFBDF3 for ; Fri, 26 Aug 2005 14:36:33 +0200 (CEST) Received: from will.iki.fi (will.iki.fi [217.169.64.20]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j7QCaWLI012677 for ; Fri, 26 Aug 2005 14:36:33 +0200 Received: from [10.0.20.56] (fa-3-0-0.fw.exomi.com [217.169.64.99]) by will.iki.fi (Postfix) with ESMTP id 113B8FC; Fri, 26 Aug 2005 15:36:32 +0300 (EEST) Message-ID: <430F0CCF.3030103@exomi.com> Date: Fri, 26 Aug 2005 15:36:31 +0300 From: Ville-Pertti Keinonen User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050721) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Christophe Raffalli Cc: Jon Harrop , caml-list@yquem.inria.fr Subject: Re: [Caml-list] Re: Parameter evaluation order References: <43065B83.6050503@dravanet.hu> <430CE193.9000805@univ-savoie.fr> <430EE6A1.9040705@univ-savoie.fr> <200508261110.41183.jon@ffconsultancy.com> <430F0669.6050103@univ-savoie.fr> In-Reply-To: <430F0669.6050103@univ-savoie.fr> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Miltered: at concorde with ID 430F0CD1.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 christophe:01 raffalli:01 semicolons:01 ocaml's:01 grammar:01 ocaml:01 ...:98 ...:98 wrote:01 tail:01 expression:01 parameter:02 construct:02 cons:02 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 Christophe Raffalli wrote: > Jon Harrop a écrit : >> Semicolons are used in many places in OCaml's grammar. Would you >> expect the members of a list literal to be evaluated left-to-right, >> for example? > yes I would ... An OCaml list is built starting with the tail. Left-to-right evaluation could end up using huge amounts of temporaries. Consider an explicit implementation of lists: type 'a list = Cons of 'a * 'a list | Nil Now, you'd write the list [ a; b; c; d ] (where a, b, c and d could be complex expressions) as Cons (a, Cons (b, Cons (c, (Cons (d, Nil))))) You need to have Cons (d, Nil) before you can construct Cons (c, ...) etc. It's the innermost expression, so evaluating it first makes sense in any sensible evaluation order.