From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id AB6B6BC57 for ; Thu, 27 May 2010 13:10:50 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AiUEACLw/UuBWB4RgWdsb2JhbACeLwEBFiIiwByFEwQ X-IronPort-AV: E=Sophos;i="4.53,310,1272837600"; d="scan'208";a="63510003" Received: from mx2.imag.fr (HELO rominette.imag.fr) ([129.88.30.17]) by mail4-smtp-sop.national.inria.fr with ESMTP; 27 May 2010 13:10:50 +0200 Received: from rhin.imag.fr (rhin.imag.fr [147.171.129.2]) by rominette.imag.fr (8.13.8/8.13.8) with ESMTP id o4RB3fNH014933 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 27 May 2010 13:03:41 +0200 Received: from [147.171.129.114] (prahova.imag.fr [147.171.129.114]) by rhin.imag.fr (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id o4RBAjmQ006789; Thu, 27 May 2010 13:10:45 +0200 Message-ID: <4BFE5335.9050902@imag.fr> Date: Thu, 27 May 2010 13:10:45 +0200 From: Florent Ouchet Reply-To: florent.ouchet@imag.fr Organization: Tima/CIS User-Agent: Mozilla-Thunderbird 2.0.0.19 (X11/20090103) MIME-Version: 1.0 To: Eray Ozkural Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Static exception analysis or alternative to using exceptions References: <956439.81564.qm@web111506.mail.gq1.yahoo.com> <4BFE2881.1070705@imag.fr> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.2 (rominette.imag.fr [129.88.30.17]); Thu, 27 May 2010 13:03:41 +0200 (CEST) X-IMAG-MailScanner-Information: Please contact MI2S MIM for more information X-MailScanner-ID: o4RB3fNH014933 X-IMAG-MailScanner: Found to be clean X-IMAG-MailScanner-SpamCheck: X-IMAG-MailScanner-From: florent.ouchet@imag.fr MailScanner-NULL-Check: 1275563024.38901@e0w8NnKbdM3ret4CUDbXOQ X-Spam: no; 0.00; redefined:01 compiler:01 syntax:01 ocaml:01 eray:01 ozkural:01 nesting:01 tima:01 assimilable:98 disturbing:98 wrote:01 exception:01 exception:01 symbolic:01 caml-list:01 In VSYML [1], the exception Not_found was raised deep in the code in some functions from List and in some redefined functions (such as ocamlutils_find_assoc with a custom key comparer). This project can be assimilable to a code compiler or a code interpreter where these functions are called during the syntax tree conversion. There is not "real" problem when the exception is caught at an higher level but when the exception is not caught at the "deep-1" level, the user will likely receive the wrong error message and this error will likely be reported at the wrong position in the VHDL source file. That was just disturbing and it required some "tact" to find the exact problem. In version VSYML 1.7, I switched from exception to optional result and the application is more stable. By using optional result, the required pattern matching ensures the error handling at the deep-1 level. [1] VSYML: VHDL Symbolic Simulator in OCaml http://users-tima.imag.fr/vds/ouchet/vsyml.html - Florent Eray Ozkural a écrit : > On Thu, May 27, 2010 at 11:08 AM, Florent Ouchet wrote: > >> Hello, >> >> Same here, specially to avoid the Not_found exception. >> The optional return values gives the oportunity to have a clear view of what >> is being done if the result is not available. >> > > That depends on the code, I think. In some cases the exception may > arise from deep in the code, and it would make sense not to bother > with a lot of type overhead for many levels of nesting and function > calling. But if all you are doing is checking the success of a > function, I suppose option types will be more efficient. > > Best, > > -- Florent Ouchet PhD Student CIS/VDS Team - TIMA Laboratory