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 MAA21934; Wed, 22 Sep 2004 12:00:59 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 MAA22805 for ; Wed, 22 Sep 2004 12:00:58 +0200 (MET DST) Received: from smtp004.mail.ukl.yahoo.com (smtp004.mail.ukl.yahoo.com [217.12.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with SMTP id i8MA0v8F011787 for ; Wed, 22 Sep 2004 12:00:57 +0200 Received: from unknown (HELO yahoo.fr) (sejourne?kevin@82.121.18.170 with plain) by smtp004.mail.ukl.yahoo.com with SMTP; 22 Sep 2004 08:59:18 -0000 Message-ID: <41513FF1.3090402@yahoo.fr> Date: Wed, 22 Sep 2004 11:03:45 +0200 From: sejourne_kevin User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040528 Debian/1.6-7 X-Accept-Language: fr-fr MIME-Version: 1.0 To: caml-list Subject: Re: [Caml-list] Re: OCAML Downcasting? References: <87isa76z7g.fsf@qrnik.zagroda> <1095819964.2580.1016.camel@pelican.wigram> <87d60eizlh.fsf@qrnik.zagroda> In-Reply-To: <87d60eizlh.fsf@qrnik.zagroda> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 41514D59.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 downcasting:01 marcin:01 'qrczak':01 kowalczyk:01 sourceforge:01 downcasts:01 downcast:01 printexc:01 anyhow:01 ocaml:01 ocaml:01 variants:01 variants:01 writes:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Marcin 'Qrczak' Kowalczyk wrote: > skaller writes: > > >>>Attempts to avoid downcasts are often unmodular, they require to >>>specify all possible variants in one place. >> >>It makes no difference. You have do specify them all anyhow, >>downcast or not. > > > It makes a difference because specifying them at the type definition > would introduce a dependency loop between modules. And it would be > unmodular: it would require changing some base module whenever a far > client module is added. > > Apply this reasoning to the exn type. Why don't you define all exn > constructors in one place? I think there is no problems with exceptions. But if you have problems managing exceptions in large modules have you try something like this ? here an example: I define all my exceptions like this : let errors = ref [];; (*to define an error*) (*errors "the exception" , the new value*) errors := ("div by zero" ,0) :: (!errors);; And the functions catch errors in this way: let truc () = try ... with ... all Ocaml pre-defined exceptions | exn -> (* my exceptions in errors list ref *) let s = Printexc.to_string exn in ... Lex & Parse 's' in (fst errors) ref list , then handle error ... ;; If exceptions are complex I can use polymorphic variants for the "new value". ------------------- 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