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 A3DE27EE35 for ; Thu, 7 Apr 2016 18:36:50 +0200 (CEST) IronPort-PHdr: 9a23:YwKE7xYeiFA8lpmKr5ddgBb/LSx+4OfEezUN459isYplN5qZpM27bnLW6fgltlLVR4KTs6sC0LqG9fy7Ej1bqb+681k8M7V0HycfjssXmwFySOWkMmbcaMDQUiohAc5ZX0Vk9XzoeWJcGcL5ekGA6ibqtW1aJBzzOEJPK/jvHcaK1oLsh7D0p8aYMl4ArQH+SI0xBS3+lR/WuMgSjNkqAYcK4TyNnEF1ff9Lz3hjP1OZkkW0zM6x+Jl+73YY4Kp5pIZoGJ/3dKUgTLFeEC9ucyVsvJWq5i/4UBCX63AAfmITmxtOS0iZvVCpFqv25wfzsOtw3B6wqcvkSbF8DTir6aZmTFnilSoBJTo42GzNkMVsjbtGrVSqp0os7ZTTZdS6PfBkf67ZNegRRWdbU9wZAyNICJm9Yo9JFOEBMPxVtaHyolIPqV21Agz6V7Cn8SNBmnKjhf5y6O8mCwyTmVF5Eg== Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=gabriel.scherer@gmail.com; spf=Pass smtp.mailfrom=gabriel.scherer@gmail.com; spf=None smtp.helo=postmaster@mail-ig0-f181.google.com Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of gabriel.scherer@gmail.com) identity=pra; client-ip=209.85.213.181; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="gabriel.scherer@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of gabriel.scherer@gmail.com designates 209.85.213.181 as permitted sender) identity=mailfrom; client-ip=209.85.213.181; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="gabriel.scherer@gmail.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@mail-ig0-f181.google.com) identity=helo; client-ip=209.85.213.181; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="postmaster@mail-ig0-f181.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0ANAgDQiwZXi7XVVdFdg1U1fQaoJoFRhV2MfyGFbAKBPAc8EAEBAQEBAQEBEQEBAQgLCwkfMYItghUBAQQSEQQZARsSCwEDDAYFCw0CAgkdAgIiAREBBQEKEgYTEhCHbwEDEg6hdoExPjGLNoFqgleHSgoZJwMKUYRHAQEBAQEFAQEBAQEVAQUKBW2FJYRLhD2DAoJWBYYvDJFJgVSEI4gVgjWMWY1nER6BDjeCIh6BbiAwiHMBAQE X-IPAS-Result: A0ANAgDQiwZXi7XVVdFdg1U1fQaoJoFRhV2MfyGFbAKBPAc8EAEBAQEBAQEBEQEBAQgLCwkfMYItghUBAQQSEQQZARsSCwEDDAYFCw0CAgkdAgIiAREBBQEKEgYTEhCHbwEDEg6hdoExPjGLNoFqgleHSgoZJwMKUYRHAQEBAQEFAQEBAQEVAQUKBW2FJYRLhD2DAoJWBYYvDJFJgVSEI4gVgjWMWY1nER6BDjeCIh6BbiAwiHMBAQE X-IronPort-AV: E=Sophos;i="5.24,449,1454972400"; d="scan'208";a="212777153" Received: from mail-ig0-f181.google.com ([209.85.213.181]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 07 Apr 2016 18:36:49 +0200 Received: by mail-ig0-f181.google.com with SMTP id gy3so105885192igb.0 for ; Thu, 07 Apr 2016 09:36:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=Uf6w+TItuAFvj0KwGaAwLhMCiKoG/WcmcGx+2zzMqNY=; b=uuQskVReEe3+ULVIfao/vFBy0aBziO0LW9Nsfp6+iEXY5AjIgv5qmAK67eBzQZax/x 18U0mQiH90O2S6i03puEUcCZa/0Hr5m6MZZCFq/okaN+rWgWPcV73FSXPdPBioOAljOz 8/XgutNr6mXiHJ0cPSbA4Z/7/jaF7t32i43uLUvxM/JtxnEtqt5KhG5DzFKBxuxLdT5Y kpZCwJc/u1vCsQkV4FwdSDekWflzrBy2kVDby7Mjvi1fjm0So3MyXAJFsceWpQcERGde sARvOxpV9GMFWBnp9Z3TGYRbSg+j0ApDku9TE3/P8MWL4/bDz7fteiCBPRbGMNxuLKYi +nnQ== 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:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=Uf6w+TItuAFvj0KwGaAwLhMCiKoG/WcmcGx+2zzMqNY=; b=HqZITlaIt4winV93Ky8Vvdr7c4YrrLJL3nDPYgYjPYXF7xfVRELLog6inraj1LdMhJ KvLfsZeKbcIJJHtVqilbU1uwVOQa1j8A6UpEoNAIMHPZXrHqGzUT5fVlb73s6xhsOZo7 6OaX+jQpqdrgWv47IQeI3kkJAwVhwHp9JWzLDeaXwPNQ1TJXcj5tDNFJY+xGGejBBfLJ Jh/WiskbtLKlNOsAvXbTb5pUbjYP/hBYhrG67geHo5JFk7iMU4BLiTjQvhi6oachbTH1 MU3MxFLRuXLZy49il0DJtOCNIneQQP+YHI0O2FrVZ5oucjhtXBdY7GHg3UoEZPXkq6AY +WLg== X-Gm-Message-State: AD7BkJK8DxMrlG4gYxzoiBc0o4twOPsG6g8xjp4c0hBditQ5bUcoPDJM7I6JN3RRaudSnDieiEhFgHy8Cu61Qw== X-Received: by 10.50.152.97 with SMTP id ux1mr4491299igb.42.1460047008737; Thu, 07 Apr 2016 09:36:48 -0700 (PDT) MIME-Version: 1.0 Received: by 10.79.17.4 with HTTP; Thu, 7 Apr 2016 09:36:09 -0700 (PDT) In-Reply-To: <91DFDE4DE82E4A8B983A7822E695BBA4@erratique.ch> References: <91DFDE4DE82E4A8B983A7822E695BBA4@erratique.ch> From: Gabriel Scherer Date: Thu, 7 Apr 2016 12:36:09 -0400 Message-ID: To: =?UTF-8?Q?Daniel_B=C3=BCnzli?= Cc: OCaml List Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Caml-list] Suboptimal pattern matching specification No, indeed you have to use a local definition to avoid code duplication in this case. My understanding of the design stance of pattern-matching in OCaml is as follows: the syntax of patterns is bounded by what can be matched efficiently. This explains why "when" has a second-class status (first-class when cannot be matched efficiently); sometimes the user has to pay for this rigidity. But, on the positive side, it is a simple and clear stance, and it correlates with the availability of good tooling, namely exhaustivity and useless-clause warnings. On Thu, Apr 7, 2016 at 9:36 AM, Daniel B=C3=BCnzli wrote: > Hello, > > Something I run quite often is the following pattern matching > > match v with > | None | Some c when sat c -> expr > | Some =E2=80=A6 > > which doesn't compile and forces me to write > > match v with > | None -> expr > | Some c when sat c -> expr > | Some =E2=80=A6 > > and leads to code duplication or the introduction of a definition to avoi= d it. > > Am I missing a syntax bit ? > > Best, > > Daniel > > > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa.inria.fr/sympa/arc/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs