From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 8D68FBBBB for ; Tue, 28 Feb 2006 13:30:26 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k1SCUQOV024874 for ; Tue, 28 Feb 2006 13:30:26 +0100 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id NAA09447 for ; Tue, 28 Feb 2006 13:30:25 +0100 (MET) Received: from sMtp.neuf.fr (sp604002mt.neufgp.fr [84.96.92.61]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k1SCUNA3012440 for ; Tue, 28 Feb 2006 13:30:25 +0100 Received: from bolet.myco.ath.cx ([84.6.204.239]) by sp604002mt.gpm.neuf.ld (Sun Java System Messaging Server 6.2-4.03 (built Sep 22 2005)) with ESMTP id <0IVE006CSDCLM301@sp604002mt.gpm.neuf.ld> for caml-list@inria.fr; Tue, 28 Feb 2006 13:29:09 +0100 (CET) Received: from localhost ([127.0.0.1] helo=myco.ath.cx ident=www-data) by bolet.myco.ath.cx with smtp (Exim 4.50) id 1FE3yQ-0001uR-Mb for caml-list@inria.fr; Tue, 28 Feb 2006 13:29:02 +0100 Date: Tue, 28 Feb 2006 13:29:02 +0100 From: Louis Gesbert Subject: Bugs with pattern-matching and exceptions To: caml-list@inria.fr Reply-To: louis.gesbert@laposte.net Message-id: MIME-version: 1.0 X-Mailer: Hastymail 1.4 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT X-Priority: 3 X-j-chkmail-Score: MSGID : 4404425F.001 on nez-perce : j-chkmail score : X : 0/20 1 X-Miltered: at concorde with ID 44044262.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 4404425F.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; ocaml:01 marshalling:01 arises:01 bug:01 ocaml:01 syntax:01 exn:01 exn:01 redefining:01 bool:01 bool:01 toplevel:01 semantics:01 marshalling:01 equality: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.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.3 There seems to be some problems with exceptions related to pattern-matching in Ocaml. First, exceptions don't support marshalling. This problem is already known, but yet undocumented. The problem doesn't arises when an exception is marshalled or unmarshalled however, but only when you try to pattern-match the un-marshalled value -- which, in my experience, hangs the program --. Equality tests work fine. I managed to build a workaround for this problem using ugly Obj code, but some feedback on wether this problem is going to be solved in future versions of Caml would be appreciated. More recently, I discovered a far worse bug which leads to some inconsistency. Ocaml offers a syntax " exception E' = E " to create an alias to an exception, which I have hardly ever seen used (with reason, it seems). See the following code: # exception E;; exception E # exception E' = E;; exception E' # exception E;; exception E # E;; - : exn = E # E';; - : exn = E (* At this stage, E and E' should be two distinct exceptions both called E. Nothing wrong yet, that kind of weird situation can also be created with types (redefining a type when objects of this type exist) *) # E = E';; - : bool = true # match E with E' -> true | _ -> false;; - : bool = false The exceptions are equal, but don't match according to the toplevel... my opinion is that they should be different in both cases: they were defined separately with two different definitions of "exception E". When E is parametrised with a type, this can lead to a failure of the type system (objects of type t = T are shown as int = 0 !) This is with Caml 3.08.3, but it doesn't seem to have been corrected in earlier versions. Any ideas ? If the structure exception E = F is considered useful, a stronger semantics should be attached to it, but is it really ? These two problems point to the handling of pattern-matching of exceptions, maybe not the marshalling of exceptions itself. Could someone explain where this weakness comes from (implementation of the extensible variable type ?) Regards, Louis Gesbert