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 DB2D07F7C2 for ; Thu, 6 Feb 2014 12:10:24 +0100 (CET) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of bmillwood@janestreet.com) identity=pra; client-ip=38.105.200.229; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="bmillwood@janestreet.com"; x-sender="bmillwood@janestreet.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of bmillwood@janestreet.com designates 38.105.200.229 as permitted sender) identity=mailfrom; client-ip=38.105.200.229; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="bmillwood@janestreet.com"; x-sender="bmillwood@janestreet.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@tot-dmz-mxout1.janestreet.com) identity=helo; client-ip=38.105.200.229; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="bmillwood@janestreet.com"; x-sender="postmaster@tot-dmz-mxout1.janestreet.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqoBAFZs81ImacjlnGdsb2JhbABZhBu+boEBHg4BAQEBAQYWCTyCJQEBBAEnGQEBNwEECwsEBzsiEgEFARwGE4dxAwkIAwKhGosVhFIBBZQmIoh4EQaOegeEOJgvkDQYKYRZ X-IPAS-Result: AqoBAFZs81ImacjlnGdsb2JhbABZhBu+boEBHg4BAQEBAQYWCTyCJQEBBAEnGQEBNwEECwsEBzsiEgEFARwGE4dxAwkIAwKhGosVhFIBBZQmIoh4EQaOegeEOJgvkDQYKYRZ X-IronPort-AV: E=Sophos;i="4.95,793,1384297200"; d="scan'208";a="57120258" Received: from mx5.janestreet.com (HELO tot-dmz-mxout1.janestreet.com) ([38.105.200.229]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 06 Feb 2014 12:10:24 +0100 Received: from tot-oib-smtp1.delacy.com ([172.27.22.15] helo=tot-smtp) by tot-dmz-mxout1.janestreet.com with esmtp (Exim 4.76) (envelope-from ) id 1WBMqb-0003Q1-QG for caml-list@inria.fr; Thu, 06 Feb 2014 06:10:21 -0500 Received: from tot-dmz-mxgoog1.delacy.com ([172.27.224.14] helo=mxgoog2.janestreet.com) by tot-smtp with esmtps (TLSv1:AES256-SHA:256) (Exim 4.72) (envelope-from ) id 1WBMqb-0000Se-PE for caml-list@inria.fr; Thu, 06 Feb 2014 06:10:21 -0500 Received: from mail-qa0-f53.google.com ([209.85.216.53]) by mxgoog2.janestreet.com with esmtp (Exim 4.76) (envelope-from ) id 1WBMqb-0006Cy-LT for caml-list@inria.fr; Thu, 06 Feb 2014 06:10:21 -0500 Received: by mail-qa0-f53.google.com with SMTP id cm18so2457926qab.40 for ; Thu, 06 Feb 2014 03:10:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=google; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=AaAjbQaBPjYL4o41cXyjW96iLgvkU7Ifoz8imaoUUjk=; b=nyfSbDv5f2H2W+OESuz3JVDnl2xoMoy4LsczO9zqmjyU3E6O8IdWM2L07nTw77For4 DFsOoIZh+hcyQ6vsQSckaMzLjUL3rdEZ+tReGsNCNiuoHhXOc+e2BTCEgpIho/bQXllN +jpZvBILSbGUZGwY9GCseruppIzywaV5sLpUc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=AaAjbQaBPjYL4o41cXyjW96iLgvkU7Ifoz8imaoUUjk=; b=d9jWsBeCg2sD4mKqzchyjC3gO+YB5Sb5dSP5FtK2oV0Z9yOfW3RETQc9/A/juMQnwZ JKzXflQAAunQ9kuosS3E3ySqglM+Enyb826Cb+Pli1g88NCgiIJNEjGAPy/Ji/gbLULl aYaihEEd6bvNBSb3WhqIVYvWdOye9TMPPQMFSuufufgwGMtKRTgVUUlHQ0LCUiDQr/A9 hxMAqo8JKd2T74p94xtUZVPwpNsUL5JXupgMb00bm3U/w4/zBi4YxBin6YPFrKsX4ivI 5Z55ph23tL0HO0Cr/NHClOnsaRFYs8WAkRO+jnf84NI8GLF57e7qwVdh9HjPq7Dukqz5 1Bqw== X-Gm-Message-State: ALoCoQkQ23K+b90R2sweqDOg4KUXMyH92UIYsWsC/2OpcdQ7uH0JFWHTK96AEm/khGbTaqGnyt/A8LjdEEWqCEsQ7Xj6mvgBMUaIXzEoZwz7/9zpspC8FNU2EEdvZ6hYyC42SD5X6VM/8DVl0sbnyLkQUeQRFUu/Jw== X-Received: by 10.224.97.67 with SMTP id k3mr11358226qan.17.1391685021518; Thu, 06 Feb 2014 03:10:21 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.224.97.67 with SMTP id k3mr11358217qan.17.1391685021432; Thu, 06 Feb 2014 03:10:21 -0800 (PST) Received: by 10.140.25.225 with HTTP; Thu, 6 Feb 2014 03:10:21 -0800 (PST) In-Reply-To: <20140206105811.GD28534@frosties> References: <20140206105811.GD28534@frosties> Date: Thu, 6 Feb 2014 11:10:21 +0000 Message-ID: From: Ben Millwood To: Goswin von Brederlow Cc: caml-list@inria.fr Content-Type: multipart/alternative; boundary=001a11c3f2b4579a5104f1baeb6d Subject: Re: [Caml-list] Proposal: extend try to handle success --001a11c3f2b4579a5104f1baeb6d Content-Type: text/plain; charset=ISO-8859-1 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 -> (...) --001a11c3f2b4579a5104f1baeb6d Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
On 6 February 2014 10:58, Goswin von Brederlow <goswin-= v-b@web.de> wrote:
How do you match any exception but not a successfull value?

let f5 x =3D
=A0 try None
=A0 with
=A0 | Empty -> ()
=A0 | val x -> x
=A0 | _ -> 1

Or does "_" only match exceptions and "val _" any value= ?

Interesting.
So, I would assume that the behaviour of _ would be unch= anged, 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&= quot; or "exception x" aren't really patterns, but rather &qu= ot;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= -> (...)
--001a11c3f2b4579a5104f1baeb6d--