Version française
Home     About     Download     Resources     Contact us    
Browse thread
Crash reading a file
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: tmp123 <tmp123@m...>
Subject: Re: [Caml-list] Crash reading a file
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Loup Vaillant wrote:
<blockquote
 cite="mid:6f9f8f4a0802040719u6b47cef2n3c3d41b382964773@mail.gmail.com"
 type="cite">
  <pre wrap="">2008/2/4, tmp123 <a class="moz-txt-link-rfc2396E" href="mailto:tmp123@menta.net">&lt;tmp123@menta.net&gt;</a>:
  </pre>
  <blockquote type="cite">
    <pre wrap="">The following program (foo.ml):

value rec read_stdin () =
  try
    [ (input_line Pervasives.stdin) :: (read_stdin ()) ]
  with [ End_of_file -&gt; [] ];

value main () =
  read_stdin();

main();


    </pre>
  </blockquote>
  <pre wrap=""><!---->
This must be an evaluation order issue: when writing "x::xs", it is
not specified whether x will be evaluated before or after xs.

  </pre>
</blockquote>
Yes, it is. I didn't known that evaluation order was considered "not
specified", nor than usually it mades "rigth to left". <br>
<br>
<blockquote
 cite="mid:6f9f8f4a0802040719u6b47cef2n3c3d41b382964773@mail.gmail.com"
 type="cite">
  <pre wrap="">they will cause your stack to overflow anyway,
since this function is not tail recursive.

  </pre>
</blockquote>
<br>
The input files will be small ones (less than 10 lines). Of course, I
preferred a tail recursive function, but then I must append at the end
of a list, that is something time consuming. I do not known about more
options.<br>
<blockquote
 cite="mid:6f9f8f4a0802040719u6b47cef2n3c3d41b382964773@mail.gmail.com"
 type="cite">
  <pre wrap="">Cheers,
Loup

  </pre>
</blockquote>
Thanks a lot to all person who have answered.<br>
<br>
Kind regards.<br>
</body>
</html>