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 PAA19286; Fri, 2 Apr 2004 15:48:03 +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 PAA26993 for ; Fri, 2 Apr 2004 15:48:02 +0200 (MET DST) Received: from decis.be ([194.78.219.157]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i32Dm1YM008369 for ; Fri, 2 Apr 2004 15:48:01 +0200 Received: from decis.be ([192.168.0.20]) (authenticated user fplancke@decis.be) by decis.be (decis.be [194.78.219.157]) (MDaemon.PRO.v7.0.1.R) with ESMTP id md50000004752.msg for ; Fri, 02 Apr 2004 15:49:31 +0200 Message-ID: <406D6F64.EDFA2445@decis.be> Date: Fri, 02 Apr 2004 13:49:24 +0000 From: Frederic van der Plancke Reply-To: fvdp@decis.be Organization: Decis X-Mailer: Mozilla 4.77 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 To: caml-list@pauillac.inria.fr Subject: Re: [Caml-list] failwith, raise and type inference References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Authenticated-Sender: fplancke@decis.be X-Spam-Processed: decis.be, Fri, 02 Apr 2004 15:49:31 +0200 (not processed: message from valid local sender) X-MDRemoteIP: 192.168.0.20 X-Return-Path: fvdp@decis.be X-MDaemon-Deliver-To: caml-list@pauillac.inria.fr X-Miltered: at concorde by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; plancke:01 fvdp:01 caml-list:01 failwith:01 inference:01 bug:01 failwith:01 3.07:01 avalue:01 avalue:01 val:01 val:01 rendez-vous:99 newton:99 bug:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk X-Status: X-Keywords: X-UID: 27 Just a small precedence bug. failwith "The key " ^ key ^ " could not be found" is equivalent to: (failwith "The key ") ^ key ^ " could not be found" and not to: failwith ("The key " ^ key ^ " could not be found") F. Paul Guyot wrote: > > Hello, > > My students came up with a behavior of ocaml I couldn't explain. > I have exactly the same result with 3.07pl2 and a fresh copy checked > out from CVS. > > >let rec f1 key dict = > > match dict with > > [] -> failwith "The key " ^ key ^ " could not be found" > > | (aKey, aValue)::tail -> > > if (aKey = key) > > then aValue > > else f1 key tail;; > > is of type: > > val f1 : string -> (string * string) list -> string = > > while: > > >exception SomeException of string;; > > > >let rec f2 key dict = > > match dict with > > [] -> raise (SomeException key) > > | (aKey, aValue)::tail -> > > if (aKey = key) > > then aValue > > else f2 key tail;; > > is of type: > > val f2 : string -> (string * 'a) list -> 'a = > > Considering that failwith is of type string -> 'a and raise of type > exn -> 'a, I couldn't figure out why the correct type for f is only > infered with raise. > > Any idea? > > Paul > -- > Philosophie de baignoire - consultations sur rendez-vous. > > NPDS/NewtonOS: http://newton.kallisys.net:8080/ > Apache/FreeBSD: http://www.kallisys.com/ > > ------------------- > To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr > Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners