From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 1B1F2BB81 for ; Fri, 13 Jan 2006 18:23:10 +0100 (CET) Received: from beaune.inria.fr (beaune.inria.fr [128.93.8.3]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k0DHN9Qr024651 for ; Fri, 13 Jan 2006 18:23:09 +0100 Received: from localhost.localdomain by beaune.inria.fr (8.8.8/1.1.22.3/14Sep99-0328PM) id SAA0000007413; Fri, 13 Jan 2006 18:23:09 +0100 (MET) Date: Fri, 13 Jan 2006 18:23:10 +0100 From: Virgile Prevosto Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Printexc cannot print some (but not all) exceptions Message-ID: <20060113182310.60349897@localhost.localdomain> In-Reply-To: <20060113163627.GB14618@furbychan.cocan.org> References: <20060113152333.GA14618@furbychan.cocan.org> <20060113165436.1e64f458@localhost.localdomain> <20060113163627.GB14618@furbychan.cocan.org> X-Mailer: Sylpheed-Claws 1.9.100 (GTK+ 2.8.9; i486-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Miltered: at nez-perce with ID 43C7E1FD.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 printexc:01 printexc:01 lib:01 ocaml:01 tutto:98 oggi:98 volta:98 exception:01 exception:01 constructor:01 pair:01 exceptions:01 cma:01 int:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 Le ven 13 jan 2006 16:36:29 CET, Richard Jones a écrit: > exception Http_error of (int * string);; > (* The server sent an error message. The left component of the pair is > * the error code, the right component is the error text. > *) > > I'll resort to using Std.dump to find out what's in the exception, > although it would be nice if Printexc could look inside the tuple and > print its contents. > The main issue is that Printexc has no way to know that it is a tuple and not the value of a sum type whose first non-constant constructor takes two arguments. For Std.dump, such a value is a tuple, but it could also have identified it with a list: #require "extlib";; /home/prevosto/softs/godi/lib/ocaml/pkg-lib/extlib: added to search path #load "extlib.cma";; # exception Wrong of (int * int);; exception Wrong of (int * int) # Std.dump (Wrong (1,0));; - : string = "[(\"Wrong\"); 1]" I think that for a function of the standard library it is safer to make a more conservative choice. -- E tutto per oggi, a la prossima volta Virgile