From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id IAA22437; Fri, 24 Aug 2001 08:53:55 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id IAA22349 for ; Fri, 24 Aug 2001 08:53:54 +0200 (MET DST) Received: from mailrelay1.inwind.it (mailrelay1.inwind.it [212.141.54.101]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f7O6rfj20391 for ; Fri, 24 Aug 2001 08:53:53 +0200 (MET DST) Received: from dalamar.krynn.it (62.98.127.32) by mailrelay1.inwind.it (5.5.029) id 3B83A8CA000392B1; Fri, 24 Aug 2001 08:53:32 +0200 Received: from kitiara.krynn.it (kitiara.krynn.it [192.168.1.116]) by dalamar.krynn.it (8.12.0.Beta7/8.12.0.Beta7/Debian 8.12.0-1) with ESMTP id f7O6ptK9000613; Fri, 24 Aug 2001 08:51:55 +0200 Received: from kitiara.krynn.it (kitiara.krynn.it [127.0.0.1]) by kitiara.krynn.it (8.12.0.Beta16/8.12.0.Beta16/Debian 8.12.0.Beta16) with ESMTP id f7O6pvai000789; Fri, 24 Aug 2001 08:51:57 +0200 Received: (from zack@localhost) by kitiara.krynn.it (8.12.0.Beta16/8.12.0.Beta16/Debian 8.12.0.Beta16) id f7O6pucM000787; Fri, 24 Aug 2001 08:51:56 +0200 Date: Fri, 24 Aug 2001 08:51:56 +0200 From: Stefano Zacchiroli To: Collin Monahan Cc: caml-list@inria.fr Subject: Re: FW: [Caml-list] newbie questions Message-ID: <20010824085156.A757@cs.unibo.it> Mail-Followup-To: Collin Monahan , caml-list@inria.fr References: <001501c12b38$50c3d9a0$f54258c0@CONSULTING2000P> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <001501c12b38$50c3d9a0$f54258c0@CONSULTING2000P> User-Agent: Mutt/1.3.20i Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Wed, Aug 22, 2001 at 02:29:01PM -0400, Collin Monahan wrote: > Well, here's a few things I don't understand right now. > > try > let chan = open_in "foobar" > with Sys_error -> > print_string "error opening file\n";; > > This doesn't work. I think it might be because the stuff in the first > part doesn't evaluate to the same type as the stuff in the second part. > I also wonder if it might have something to do with how in the > documentation, lots of exceptions are described as, for example > exception Stack_overflow > but for Sys_error it says > exception Sys_error of string Exception are like others concrete type in OCaml the only difference is that them are introduced with the keywork "exception". When you define an exception you may define it with a variable number of arguments; exception like "Stack_overflow" are exception with no argument, exception like "Sys_error" are exception with one argument, in particular "Sys_error" have one string argument (this is because the same exception is used to report a lot of different errors). In "try ... with" constructor, the "with" clause use a pattern matching on the exception returned by the "try" clause that return an "Exception of string" that is not matched by your pattern of the form "Exception". You have to use something like: try ... with Sys_error -> print_string ... Hope this helps ... Cheers -- Stefano "Zack" Zacchiroli ICQ# 33538863 Home Page: http://www.students.cs.unibo.it/~zacchiro Undergraduate student of Computer Science @ University of Bologna, Italy - Information wants to be Open - ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr