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.0 required=5.0 tests=none 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 902C4BC0A for ; Mon, 19 Feb 2007 01:11:47 +0100 (CET) Received: from mailout1.informatik.tu-muenchen.de (mailout1.informatik.tu-muenchen.de [131.159.0.18]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l1J0Blnc016175 for ; Mon, 19 Feb 2007 01:11:47 +0100 Received: from [192.168.1.108] (c-69-253-130-19.hsd1.nj.comcast.net [69.253.130.19]) by mail.in.tum.de (Postfix) with ESMTP id 737F3277C for ; Mon, 19 Feb 2007 01:11:46 +0100 (MET) Message-ID: <45D8EB3E.7010002@in.tum.de> Date: Sun, 18 Feb 2007 19:11:42 -0500 From: christian konrad User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050915 X-Accept-Language: en-us, en MIME-Version: 1.0 To: caml-list@inria.fr Subject: Re: [Caml-list] Question about try.. with References: <45D79283.8000101@in.tum.de> <20070218.181909.64993949.garrigue@math.nagoya-u.ac.jp> In-Reply-To: <20070218.181909.64993949.garrigue@math.nagoya-u.ac.jp> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new/sophie/sophos at mailrelay1.informatik.tu-muenchen.de X-Miltered: at discorde with ID 45D8EB43.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; recursion:01 recursion:01 cheers:01 infile:01 infile:01 recursive:01 ocaml:01 recursive:01 beginners:01 wrote:01 rec:01 exception:01 caml-list:01 exceptions:01 tail:01 Thanks for all those hints. For the future I will use the beginners list, thank you. 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? Thanks and cheers, Chris Jacques Garrigue wrote: >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 > > >