Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Damien Doligez <damien.doligez@inria.fr>
To: caml-list <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] Re: Parameter evaluation order
Date: Wed, 24 Aug 2005 13:33:20 +0200	[thread overview]
Message-ID: <91631662-65C4-4FB7-96B1-B6C1CAF50B80@inria.fr> (raw)
In-Reply-To: <000401c5a84a$a2e79760$1866b811@Operational>


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



  reply	other threads:[~2005-08-24 11:33 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-19 22:21 "Márk S. Zoltán"
2005-08-20  9:12 ` [Caml-list] " Alain Frisch
2005-08-26 17:53   ` "Márk S. Zoltán"
2005-08-22 16:50 ` Damien Doligez
2005-08-23  7:12   ` skaller
2005-08-23 11:29     ` Damien Doligez
2005-08-23 13:34       ` Igor Pechtchanski
2005-08-23 19:52         ` Damien Doligez
2005-08-24  1:24   ` Hao-yang Wang
2005-08-24 11:33     ` Damien Doligez [this message]
2005-08-24 14:39       ` [Caml-list] " Christophe Raffalli
2005-08-24 15:47         ` Berkeley DB Joel Reymont
2005-08-24 16:08         ` [Caml-list] Re: Parameter evaluation order brogoff
2005-08-24 20:05           ` Christophe Raffalli
2005-08-24 20:25             ` brogoff
2005-08-24 20:53               ` Jon Harrop
     [not found]               ` <430CE193.9000805@univ-savoie.fr>
2005-08-26  9:53                 ` Christophe Raffalli
2005-08-26 10:10                   ` Jon Harrop
2005-08-26 12:09                     ` Christophe Raffalli
2005-08-26 12:26                       ` Diego Olivier Fernandez Pons
2005-08-26 16:48                         ` Christophe Raffalli
2005-08-27 15:33                           ` Christophe TROESTLER
2005-08-26 12:36                       ` Ville-Pertti Keinonen
2005-08-26 14:17                         ` Fernando Alegre
2005-08-26 17:00                         ` Christophe Raffalli
2005-08-26 22:58                       ` skaller

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=91631662-65C4-4FB7-96B1-B6C1CAF50B80@inria.fr \
    --to=damien.doligez@inria.fr \
    --cc=caml-list@yquem.inria.fr \
    /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