caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Andrej Bauer <Andrej.Bauer@fmf.uni-lj.si>
To: caml-list@inria.fr
Cc: christian konrad <konrad@in.tum.de>
Subject: Re: [Caml-list] Question about try.. with
Date: Mon, 19 Feb 2007 10:16:43 +0100	[thread overview]
Message-ID: <45D96AFB.50904@fmf.uni-lj.si> (raw)
In-Reply-To: <45D8EB3E.7010002@in.tum.de>

christian konrad wrote:
> But that seams really strange not to have a strictly defined order of 
> evaluation. Isn't that really bad if one would like to do some tail 
> recursion to get it compiled without recursion but as a loop?

Undefined order of evaluation allows more optimization.

Arguably, it may be confusing for the programmer (especially one who is 
used to relying on order of evaluation of arguments to a function 
call--a rather dangerous practice). But your remark about tail recursion 
is mistaken, i.e., you are suggesting that a call to a function inside 
an argument to another function might be tail-recursive, which is 
clearly impossible.

In your example, you had

   let rec readIn() =
      ....
      (input_line infile) ^ readIn()
      ....

Here we have arguments "input_line infile" and "readIn()" to the binary 
operation ^. It does not matter what the order of evaluation of the 
arguments is: readIn cannot be tail-recursive under any order, since the 
last thing that needs to happen is ^.

Best regards,

Andrej


      reply	other threads:[~2007-02-19  9:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-17 23:40 christian konrad
2007-02-18  0:37 ` [Caml-list] " Jon Harrop
2007-02-18  1:01   ` Geoffrey Romer
2007-02-18  9:20     ` Christophe TROESTLER
2007-02-18  9:19 ` Jacques Garrigue
2007-02-19  0:11   ` christian konrad
2007-02-19  9:16     ` Andrej Bauer [this message]

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=45D96AFB.50904@fmf.uni-lj.si \
    --to=andrej.bauer@fmf.uni-lj.si \
    --cc=Andrej.Bauer@andrej.com \
    --cc=caml-list@inria.fr \
    --cc=konrad@in.tum.de \
    /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;
as well as URLs for NNTP newsgroup(s).