Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: briand@aracnet.com
To: romildo@uber.com.br
Cc: caml-list@inria.fr
Subject: [Caml-list] Checking for eof
Date: Sat, 25 Dec 2004 17:58:58 -0800	[thread overview]
Message-ID: <16846.6882.973973.179486@soggy.deldotd.com> (raw)
In-Reply-To: <20041226011212.GA10516@gentoo.malaquias.no-ip.org>


Youa are actually looking for an eof exception.

Here is a code segment which demonstrates this nicely and won't blow
up the stack.

let readfile chan =
  let rec loop rlst =
    let line, eof = 
      try
        (input_line chan), false
      with
        | End_of_file -> "", true
    in
      if not eof then
	(
          loop (line :: rlst);
	)
      else
        List.rev rlst
  in
    loop []
;;

Brian


  reply	other threads:[~2004-12-26  1:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-26  1:12 romildo
2004-12-26  1:58 ` briand [this message]
2004-12-26 13:09   ` [Caml-list] " Nicolas George
2004-12-27 20:23     ` Martin Jambon
2004-12-26 15:25 Don Syme
2004-12-27  0:14 ` 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=16846.6882.973973.179486@soggy.deldotd.com \
    --to=briand@aracnet.com \
    --cc=caml-list@inria.fr \
    --cc=romildo@uber.com.br \
    /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