From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id C43217F7B4 for ; Mon, 10 Feb 2014 09:47:47 +0100 (CET) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of goswin-v-b@web.de) identity=pra; client-ip=212.227.15.4; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="goswin-v-b@web.de"; x-sender="goswin-v-b@web.de"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of goswin-v-b@web.de) identity=mailfrom; client-ip=212.227.15.4; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="goswin-v-b@web.de"; x-sender="goswin-v-b@web.de"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mout.web.de) identity=helo; client-ip=212.227.15.4; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="goswin-v-b@web.de"; x-sender="postmaster@mout.web.de"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: At4BAOuQ+FLU4w8EnGdsb2JhbABZvgmFX4EKFg4BAQEBAQYNCQkUKIIlAQEFJxNPCxgJJQ8FKDSHcAEDEQS/VB8rIogxF48EFoMOgRQEmCqGMhKPDA X-IPAS-Result: At4BAOuQ+FLU4w8EnGdsb2JhbABZvgmFX4EKFg4BAQEBAQYNCQkUKIIlAQEFJxNPCxgJJQ8FKDSHcAEDEQS/VB8rIogxF48EFoMOgRQEmCqGMhKPDA X-IronPort-AV: E=Sophos;i="4.95,816,1384297200"; d="scan'208";a="57637454" Received: from mout.web.de ([212.227.15.4]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES128-SHA; 10 Feb 2014 09:47:47 +0100 Received: from frosties.localnet ([149.172.224.32]) by smtp.web.de (mrweb103) with ESMTPSA (Nemesis) id 0LfztP-1VOthp2zzH-00pefH for ; Mon, 10 Feb 2014 09:47:46 +0100 Received: from mrvn by frosties.localnet with local (Exim 4.80) (envelope-from ) id 1WCmWo-00070d-8B for caml-list@inria.fr; Mon, 10 Feb 2014 09:47:46 +0100 Date: Mon, 10 Feb 2014 09:47:46 +0100 From: Goswin von Brederlow To: caml-list@inria.fr Message-ID: <20140210084746.GB26593@frosties> References: <20140206105811.GD28534@frosties> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Provags-ID: V03:K0:rZArN4xKEs5iSY8NmqPyYknIWgW9SVrewWt1f+W3E9wyjTtZSho meSJ9uZ4ukMsJy2g1mv4RmlbJjf2jvoZZ/SnRFbd8iASN1x/ui2P7LgiftuyxHyQV6SXg4s oLWMQdPy71UYVr/wP9iy/oyVrit3SA3D0bmXKc0duu+qBJsbLxAuIfaMChcpQ72p/ZCsAvT h3f8n0nIOzrlTw7A3WCgA== Subject: Re: [Caml-list] Proposal: extend try to handle success On Thu, Feb 06, 2014 at 11:10:21AM +0000, Ben Millwood wrote: > On 6 February 2014 10:58, Goswin von Brederlow wrote: > > > How do you match any exception but not a successfull value? > > > > let f5 x = > > try None > > with > > | Empty -> () > > | val x -> x > > | _ -> 1 > > > > Or does "_" only match exceptions and "val _" any value? > > > > Interesting. > > So, I would assume that the behaviour of _ would be unchanged, so it would > match any exception and no value in a try and any value and no exception in > a match. > > The way I justify this is that "val x" or "exception x" aren't really > patterns, but rather "x" is a pattern and val/exception are part of the > try/match syntax. For example, "val (val x)" would presumably be a parse > error. As such, "_" isn't a more general pattern than "val _", because > they're different kinds of thing. > > This makes me wonder if the current syntax is misleadingly uniform. Perhaps > value and exception cases ought to be more clearly separated, e.g. > > try (...) > with val > | Some x -> (...) > | None -> (...) > with exception > | Not_found -> (...) That would break every existing source using exceptions. Unless the exception in "with exception" is only required when using "with val". Maybe "with val" should better be a single keyword like try (...) val | Some x -> (...) | None -> (...) with | Not_found -> (...) MfG Goswin