From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id ACA12BC0A for ; Sun, 18 Feb 2007 10:19:23 +0100 (CET) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l1I9JLxu018786 for ; Sun, 18 Feb 2007 10:19:22 +0100 Received: from localhost (orion [130.54.16.5]) by kurims.kurims.kyoto-u.ac.jp (8.13.7/8.13.7) with ESMTP id l1I9JFCW019166; Sun, 18 Feb 2007 18:19:15 +0900 (JST) Date: Sun, 18 Feb 2007 18:19:09 +0900 (JST) Message-Id: <20070218.181909.64993949.garrigue@math.nagoya-u.ac.jp> To: konrad@in.tum.de Cc: caml-list@inria.fr Subject: Re: [Caml-list] Question about try.. with From: Jacques Garrigue In-Reply-To: <45D79283.8000101@in.tum.de> References: <45D79283.8000101@in.tum.de> X-Mailer: Mew version 4.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at discorde with ID 45D81A19.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; infile:01 infile:01 recursive:01 ocaml:01 recursive:01 rec:01 exception:01 caml-list:01 exceptions:01 undefined:01 output:02 string:02 garrigue:03 garrigue:03 sys:03 From: christian konrad > I'm doing that: > > let _ = > try > let infile = open_in !filename in > let rec readIn () = > try > (input_line infile) ^ readIn(); > with ee -> ""; > in > print_string(readIn () ); > "good"; > with e -> "";; > > So why don't I get any output at all? Doesn't "with" erease the raised > Exception? Because you assume wrongly that input_line will be called before the recursive call to readIn. Nothing in the ocaml specification says so (evaluation order is left undefined.) In practice the rightmost call is done first, which is the recursive call here, but you shouldn't depend on it either. By the way, it is a bad idea to catch all exceptions. ee should be End_of_file and e should be Sys_error _. Jacques Garrigue