From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.9 required=5.0 tests=DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 5AB12BBAF for ; Fri, 21 Nov 2008 03:56:04 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjcAAFSyJUnY/EBGkWdsb2JhbACBbZFtAQEBAQkLCgcRBL4Ignw X-IronPort-AV: E=Sophos;i="4.33,639,1220220000"; d="scan'208";a="17438542" Received: from mail.colba.net (HELO mailhost1.enter-net.com) ([216.252.64.70]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 21 Nov 2008 03:56:03 +0100 Received: (qmail-ldap/ctrl 32601 invoked from network); 21 Nov 2008 03:01:35 -0000 Received: from unknown (HELO [192.168.0.100]) ([216.252.88.145]) (envelope-sender ) by mailhost1.enter-net.com (qmail-ldap-1.03) with SMTP for ; 21 Nov 2008 03:01:35 -0000 Message-ID: <49262360.7040807@colba.net> Date: Thu, 20 Nov 2008 21:56:32 -0500 From: Eliot Handelman Reply-To: eliot@colba.net User-Agent: Thunderbird 2.0.0.6 (X11/20070801) MIME-Version: 1.0 To: Caml_mailing list Subject: Stability of exceptions References: <200811182330.03947.jon@ffconsultancy.com> <1227076192.6290.7.camel@Blefuscu> <4b5157c30811190146l2c6a5e2cv4a085bcc14ae5f4@mail.gmail.com> <20081119211124.51610ae9@alcazar.inria.fr> <1227172839-sup-5973@ausone.inria.fr> <20081120103303.GA25346@annexia.org> <20081120104914.GA14355@usha.takhisis.invalid> <000001c94b03$4f55d4e0$ee017ea0$@com> <1227185953-sup-4761@ausone.inria.fr> <1227188375-sup-8502@ausone.inria.fr> <20081120164406.GA6980@usha.takhisis.invalid> In-Reply-To: <20081120164406.GA6980@usha.takhisis.invalid> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; literals:01 ocaml:01 literals:01 typing:01 matched:01 exception:01 exceptions:01 exceptions:01 int:01 argument:02 bounds:02 bounds:02 match:02 string:02 string:02 In order to catch array access violations, it seems necessary to do something like this: exception Array_access of int let test i = try [||].(i) with Invalid_argument "index out of bounds" -> raise (Array_access i) The problem is that this test is dependent on a literal string match of "index out of bounds." If I accidentally write something like "index out out bounds" (an extra space between index & out) then, of course, the above code will not raise Array_access, and indeed it may be quite hard for me to discover what went wrong. This seems inconsistent with the idea of strong typing. Is there some guarantee in the language that in future releases, the "index out of bounds" message will remain exactly what it currently is? My problem is not confined to this particular case, but rather with all exceptions that have to be matched on string literals, in particular because I'm a rather poor typist. What's the common practice here? Would it not be better for Ocaml to have built-in exceptions (not string literals) for things of this importance? best, -- eliot