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 E9E34BDCE for ; Wed, 24 Aug 2005 13:33:22 +0200 (CEST) Received: from [128.93.8.130] (macadam.inria.fr [128.93.8.130]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j7OBXMq8019412 for ; Wed, 24 Aug 2005 13:33:22 +0200 In-Reply-To: <000401c5a84a$a2e79760$1866b811@Operational> References: <43065B83.6050503@dravanet.hu> <254E6767-A097-455B-872B-483725D26744@inria.fr> <000401c5a84a$a2e79760$1866b811@Operational> Mime-Version: 1.0 (Apple Message framework v733) X-Priority: 3 Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <91631662-65C4-4FB7-96B1-B6C1CAF50B80@inria.fr> Content-Transfer-Encoding: 7bit From: Damien Doligez Subject: Re: [Caml-list] Re: Parameter evaluation order Date: Wed, 24 Aug 2005 13:33:20 +0200 To: caml-list X-Mailer: Apple Mail (2.733) X-Miltered: at concorde with ID 430C5B02.002 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; damien:01 damien:01 caml-list:01 hao-yang:01 curried:01 evalue:01 curried:01 2005,:98 wrote:01 arbitrary:01 doligez:01 doligez:01 expression:01 functions:01 argument:01 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 On Aug 24, 2005, at 03:24, Hao-yang Wang wrote: >> Suppose you want to evaluate a curried function call in left-to-right >> order: >> f e1 e2 e3 e4 >> >> You must evaluate f first, then e1. Then you must apply f to e1, >> giving >> a new function g1. Then you must evalue e2, then apply f1 to e2, >> giving >> f2, etc. >> >> > > It seems to me that as long as evaluate f the last, we are ok. > Yes. > We can specify the evaluation order of the _parameters_ left-to-right > (i.e., e1 then e2, e3, e4, and finally f), without running into the > efficiency problem. > No, that is a contradiction. f is an arbitrary expression of the language, for example (g e0), so the code above might well be in fact: g e0 e1 e2 e3 e4 Now, if you evaluate f last, you are obviously not evaluating the arguments in left-to-right order, since you evaluate e0 after the others. In order to stay consistent, you have to evaluate them in right-to-left order. In fact, when all your functions are curried there are only two possible choices: evaluate the function first, or the argument first. There is no such thing as a multi-argument function application. Evaluating f last forces you to evaluate the arguments in right-to-left order in expressions like the above. -- Damien