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 nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 7244BBBBC for ; Thu, 2 Mar 2006 07:47:54 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k226lsn3016528 for ; Thu, 2 Mar 2006 07:47:54 +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 HAA13366 for ; Thu, 2 Mar 2006 07:47:53 +0100 (MET) Received: from smtp2-g19.free.fr (smtp2-g19.free.fr [212.27.42.28]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k226lrxp016525 for ; Thu, 2 Mar 2006 07:47:53 +0100 Received: from [192.168.0.2] (rke75-3-82-229-183-156.fbx.proxad.net [82.229.183.156]) by smtp2-g19.free.fr (Postfix) with ESMTP id 09FEC6CC72; Thu, 2 Mar 2006 07:47:53 +0100 (CET) Message-ID: <44069518.7030708@inria.fr> Date: Thu, 02 Mar 2006 07:47:52 +0100 From: Alain Frisch User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) X-Accept-Language: en-us, en MIME-Version: 1.0 To: louis.gesbert@laposte.net Cc: caml-list@inria.fr Subject: Re: [Caml-list] Bugs with pattern-matching and exceptions References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 4406951A.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 44069519.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; frisch:01 frisch:01 caml-list:01 integers:01 constructors:01 struct:01 stdout:01 stdin:01 endline:01 endline:01 argv:01 semantics:01 afaik:01 semantics:01 bug: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 Louis Gesbert wrote: > Let's suppose we have two processes running the exact same compiled program. I guess exceptions are too dynamic for this criterion to be useful. You could imagine an implementation of exception equality based on unique integers assigned sequentially to exception constructors when they are created. But this doesn't work in general. Consider: let f b = let module M = struct exception E end in if b then Marshal.to_channel stdout M.E [] else match Marshal.from_channel stdin with | M.E -> print_endline "Equal" | _ -> print_endline "Not equal" let () = if (Array.length Sys.argv >= 2) then f true else f false I don't see a good semantics for such a program, except considering that unmarshalled exceptions must always be different (w.r.t. pattern matching) from exceptions defined in the current program, which AFAIK is the current semantics. > However, if you try to pattern-match against it, the process just hangs. Can you give an example to reproduce that? The program above works fine. leoville ~/bug $ ./exn x | ./exn Not equal > As I understand it, the constructor Ex of the variant type exn is > represented by a pointer in (Ex "arg"), and this pointer is kept as-is by > the marshaller which doesn't understand the particular structure of > exceptions. More precisely, it doesn't distinguish an exception constructor from a string reference. Marshalling and unmarshalling produce a shallow copy. -- Alain