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 CAA18333; Sat, 28 Aug 2004 02:09:53 +0200 (MET DST) 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 CAA16708 for ; Sat, 28 Aug 2004 02:09:51 +0200 (MET DST) Received: from invasion.mail.pas.earthlink.net (invasion.mail.pas.earthlink.net [207.217.120.254]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id i7S09oLY006663 for ; Sat, 28 Aug 2004 02:09:51 +0200 Received: from 168-103-58-53.tcsn.qwest.net ([168.103.58.53] helo=dylan) by invasion.mail.pas.earthlink.net with asmtp (Exim 4.34) id 1C0qn0-0003Lc-2I; Fri, 27 Aug 2004 17:09:50 -0700 Message-ID: <000901c48c93$9bc9eec0$0201000a@dylan> From: "David McClain" To: "Brian Hurt" Cc: References: Subject: Re: [Caml-list] C++ Throws Date: Fri, 27 Aug 2004 17:11:38 -0700 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 X-ELNK-Trace: 7a0ab3eafc8cf994b22988ad1c62733440683398e744b8a40468eb2d5a212de9e9ca2bc6af2798492601a10902912494350badd9bab72f9c350badd9bab72f9c X-Originating-IP: 168.103.58.53 X-Miltered: at concorde with ID 412FCD4E.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; mcclain:01 dmcclain:01 caml-list:01 generic:01 mcclain:01 caml-list:01 2004:99 unhandled:01 abort:01 extern:01 foo:01 foo:01 mangling:01 extern:01 generic:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hi Brian, Yes, that technique is the one that I said previously works just fine. I was hoping for a higher level generic handler, instead of wrapping each individual lib call with this try-catch block. I have been doing C++ to OCaml for years now with no difficulty. The catch here is that OCaml appears to be interposing between the established higher level catch handlers and the source of the throw exceptions. It appears to insist on not allowing any lower dynamic exceptions to propagate above its interface with a C call. David McClain Senior Corporate Scientist Avisere, Inc. +1.520.390.7738 (USA) david.mcclain@avisere.com ----- Original Message ----- From: "Brian Hurt" To: "David McClain" Cc: Sent: Friday, August 27, 2004 16:24 Subject: Re: [Caml-list] C++ Throws > On Fri, 27 Aug 2004, David McClain wrote: > > > I now see that OCaml is not converting anything, per se... Apparently > > when the throw handler detects an unhandled condition it decides to > > call abort(), against which there is no defense. > > I don't know what precisely is going on here, but Ocaml interfaces to C, > which doesn't know anything about exceptions. You might try something > like (sorry, I'm no C++ guru): > > extern "C" value foo(value c); > > value foo(value C) { > /* normal Ocaml wrapper code for C */ > try { > /* exception throwing code for C++. */ > } > with (Exception e) { > /* Translate the C++ exception to an Ocaml exception */ > } > } > > The big difference between a C++ function and C function is the name > mangling. I doubt Ocaml could find a C++ function for linking after it > was name mangled. So the extern "C" tells C++ to not namemangle the > function name. > > There is no way I know of to determine what exceptions a function call > might throw. > > > So there appears to be something relatively complex going on across the > > foreign function interface with OCaml and C. This override is what > > frustrates the attempts to create a generic C++ exception handler. > > I think you also have a C/C++ interface problem (and yes, Virginia, they > do exist). > > -- > "Usenet is like a herd of performing elephants with diarrhea -- massive, > difficult to redirect, awe-inspiring, entertaining, and a source of > mind-boggling amounts of excrement when you least expect it." > - Gene Spafford > Brian > > ------------------- > 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 > ------------------- 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