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 MAA09057; Fri, 15 Feb 2002 12:15:48 +0100 (MET) 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 MAA09262 for ; Fri, 15 Feb 2002 12:15:47 +0100 (MET) Received: from audi.ibcp.fr (audi.ibcp.fr [193.51.160.127]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g1FBFl506985 for ; Fri, 15 Feb 2002 12:15:47 +0100 (MET) Received: from pc-bioinfo1.ibcp.fr (pc-bioinfo1.ibcp.fr [193.51.160.63]) by audi.ibcp.fr (Postfix) with ESMTP id EA384FC44 for ; Fri, 15 Feb 2002 12:15:46 +0100 (CET) Date: Fri, 15 Feb 2002 12:04:22 +0100 (CET) From: Martin Jambon X-X-Sender: To: Subject: Re: [Caml-list] Another q about many types Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Thu, 14 Feb 2002, Ryan Tarpine wrote: > Many thanks for the advice on polymorphic variants; they seemed to be just > what I needed. But I've run into one small problem: I can't define > exceptions with arguments of polymorphic types. > > In the language I'm trying to implement, to raise an exception, the user > needs to create an instance of an exception class. So, in my > implementation, I wanted to define an exception whose sole argument would be > an instance of a class. But, I designed instances to be records containing > a polymorphic variant, which makes the record type itself polymorphic. Is > there some way to raise exceptions with polymorphic arguments, or some other > possible way of implementing this? Maybe something like this: exception E of exn ... exception E_1 of t1 ... exception E_2 of t2 ... try ... with E e -> match e with E_1 x1 -> x1 | E_2 x2 -> some_conversion_to_t1 x2 Martin ------------------- 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