English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Checking for eof
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-12-26 (13:09)
From: Nicolas George <nicolas.george@e...>
Subject: Re: [Caml-list] Checking for eof
Le sextidi 6 nivôse, an CCXIII, briand@aracnet.com a écrit :
>       try
>         (input_line chan), false
>       with
>         | End_of_file -> "", true

I would have written that

	  Some (input_line chan)
	  | End_of_file -> None

but the idea is the same. I find it is an irritating limitation of OCaml
syntax to have to pack and then unpack all local values in order to uncatch
exceptions. Something like

	  let line = input_line chan in
          loop (line :: rlst)
	  | End_of_file -> List.rev rlst

This syntax is somewhat awkward: untry is neither a third member of the
try...with structure, because it must be inside the flow of let...in
declaration, nor a stand-alone statement, because it must not be allowed
anywhere outside try...with.

On the contrary, as far as I can see, the semantics is quite simple.