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 426B680211 for ; Thu, 19 Oct 2017 16:44:32 +0200 (CEST) Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=vrotaru.md@gmail.com; spf=Pass smtp.mailfrom=vrotaru.md@gmail.com; spf=None smtp.helo=postmaster@mail-lf0-f50.google.com Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of vrotaru.md@gmail.com) identity=pra; client-ip=209.85.215.50; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="vrotaru.md@gmail.com"; x-sender="vrotaru.md@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of vrotaru.md@gmail.com designates 209.85.215.50 as permitted sender) identity=mailfrom; client-ip=209.85.215.50; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="vrotaru.md@gmail.com"; x-sender="vrotaru.md@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-lf0-f50.google.com) identity=helo; client-ip=209.85.215.50; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="vrotaru.md@gmail.com"; x-sender="postmaster@mail-lf0-f50.google.com"; x-conformance=sidf_compatible IronPort-PHdr: =?us-ascii?q?9a23=3AK/8hzBAq4wNv+0IP1/x8UyQJP3N1i/DPJgcQr6Af?= =?us-ascii?q?oPdwSP74pMbcNUDSrc9gkEXOFd2Crakb26yL6+jJYi8p39WoiDg6aptCVhsI24?= =?us-ascii?q?09vjcLJ4q7M3D9N+PgdCcgHc5PBxdP9nC/NlVJSo6lPwWB6lX71zMZGw3+OAxp?= =?us-ascii?q?Pay1X9eK14Xk4duv4IXeaBlkgz+0YLU6bEnn7FaZis5DroJoMKc8zlPyqXtFYe?= =?us-ascii?q?lMjTdnLFiJnhv4oNy7/JN5/j54tPco9soGWqL/KfcWV7tdWX44KWcp7df28xzP?= =?us-ascii?q?ZQSK73oYFG4Rl1AAVxbf6w3zRIq3tyfSue902S3cNsrzG+NnEQ++5rtmHUe7wB?= =?us-ascii?q?wMMCQ0pSSK08E=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0CwAABuuehZhjLXVdFdGwEBAQMBAQEJA?= =?us-ascii?q?QEBFQEBAQECAQEBAQgBAQEBhBhuFBODeoE2mCKBeoJRjiOHUwojhRgChQpCFQE?= =?us-ascii?q?BAQEBAQEBAQEBEgEBAQgLCwgoL4I4BQEeBoI7AQEBAwEjBBkBGxILAQMBCwYDA?= =?us-ascii?q?gQHDQ0dAgIhAQERAQUBChIGExKJdQEDDQgQjReRG0CMDIFtGAUBHIMJBYNkChk?= =?us-ascii?q?nAwpYgwEBAQEBAQEBAQEBAQEBAQEBAQEBAQEVAgYSgx2CB1R9hRiCXoIHAQFLg?= =?us-ascii?q?meCYQWIMgyYWTwCgkMBhRuIFYR5gnGQKI0GiFoUJIEVDyaBfXpeNYIvCYJEH4F?= =?us-ascii?q?zQDaIMWCBVQEBAQ?= X-IPAS-Result: =?us-ascii?q?A0CwAABuuehZhjLXVdFdGwEBAQMBAQEJAQEBFQEBAQECAQE?= =?us-ascii?q?BAQgBAQEBhBhuFBODeoE2mCKBeoJRjiOHUwojhRgChQpCFQEBAQEBAQEBAQEBE?= =?us-ascii?q?gEBAQgLCwgoL4I4BQEeBoI7AQEBAwEjBBkBGxILAQMBCwYDAgQHDQ0dAgIhAQE?= =?us-ascii?q?RAQUBChIGExKJdQEDDQgQjReRG0CMDIFtGAUBHIMJBYNkChknAwpYgwEBAQEBA?= =?us-ascii?q?QEBAQEBAQEBAQEBAQEBAQEVAgYSgx2CB1R9hRiCXoIHAQFLgmeCYQWIMgyYWTw?= =?us-ascii?q?CgkMBhRuIFYR5gnGQKI0GiFoUJIEVDyaBfXpeNYIvCYJEH4FzQDaIMWCBVQEBA?= =?us-ascii?q?Q?= X-IronPort-AV: E=Sophos;i="5.43,402,1503352800"; d="scan'208,217";a="297025213" Received: from mail-lf0-f50.google.com ([209.85.215.50]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 19 Oct 2017 16:44:31 +0200 Received: by mail-lf0-f50.google.com with SMTP id a69so9899183lfe.5 for ; Thu, 19 Oct 2017 07:44:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xlLAngMObuexFzGEAm6la1QHWjFq+Uta66ixU0hhlb0=; b=vNI6bsXzQ58sTkr897Wm9aX+uWx4F72qjphxGRBahtiVgTK7qJjFviq5UIu3D2V1ej 8oSE7DZAFdp7M6/kuGe6RLF42s0XVgmMy7ruzI4/AmF6EYelBXy/E9qFCh5hQl7WaSgr iYLQRyIQ/F2M8I17C1EvWy0bJUAJutguvUlrF8hQbxXTZlOojcfDX99KT5LGklDfyNFy leQY6iXa7/+oKrhXCGhjTJyXTTFFNnbNFmgHcsc5ueM8gX9Lx+v+TbBRKxamHQNQfpTm IeiN9Ez8RQYUAcPc9JDM9kA2/PwkUsxRFLi6F796LUi6jUxG4CGmOIohuzk5GIvWjBGC K3tA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xlLAngMObuexFzGEAm6la1QHWjFq+Uta66ixU0hhlb0=; b=ikf1/Uii/43Mt9Ka0KFptZukn6NNR5B4ke0Omlyf69jEa6oAgWfgA5SKP5jeT/qymA kjlPFrZqpnBN+4M3MXMdO/yUD4DQTncD5qvIGZLYeVjtSNSMz+IWMRVOIz7lkEYcJfjY hguZIEwPQVG7ssQRLLEuZjmdS1UksGErjKWQONeNl1QcBmXJPv60J9xtTyJuoFMFKbvB 0WFo68Hzk50mUiay77BnWxbFnQZPUHg0mZhmyL+uWofCXLBwkT0E2wCUaTJusXvT6hKw m5MQD9r/zKk1/Qc6q/+2r/IMeEm1rALvBeETGow3dAUT3W2V80AGsPDW0fBqkFFcGQSp 3OmQ== X-Gm-Message-State: AMCzsaUynWkPDfGW7ifUunAfrc7crkuaZq6NQRvcF0npku95rND8nC6R eVVejIaGW681JTK6u8MNh7Z50sco5R5crEzfe+Q= X-Google-Smtp-Source: ABhQp+QUm6ECesCMXpjuzOPSRfVSd7JT6US/LbCwhCOMxe2/bWJsPe76KSy9Kf7s1y1UMSuE1Q3KvBw8msnOCmcQWjQ= X-Received: by 10.46.20.15 with SMTP id u15mr889533ljd.9.1508424270195; Thu, 19 Oct 2017 07:44:30 -0700 (PDT) MIME-Version: 1.0 References: <72565dd8-08e0-0fd3-a3df-6742e1957ec3@matej-kosik.net> In-Reply-To: From: "vrotaru.md@gmail.com" Date: Thu, 19 Oct 2017 14:44:19 +0000 Message-ID: To: Gabriel Scherer Cc: =?UTF-8?B?TWF0ZWogS2/FocOtaw==?= , caml users Content-Type: multipart/alternative; boundary="f403045fc074cbb30f055be7648f" Subject: Re: [Caml-list] beginner question about pattern matching --f403045fc074cbb30f055be7648f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I see, where I was wrong. But if the goal is to avoid allocation then something like [ Rtag (x, y, z, w)] -> somefn x y z w will work On Thu, Oct 19, 2017, 17:35 Gabriel Scherer wrote: > This is a small hiccup with the OCaml (non-revised) syntax: > > | Foo of bar * baz * blah > > and > > | Foo of (bar * baz * blah) > > are not equivalent, and only the latter allows to do what you want. > > > On Thu, Oct 19, 2017 at 3:38 PM, Matej Ko=C5=A1=C3=ADk wrote: > > Hi, > > > > I am trying to do simple pattern matching of these values: > > https://github.com/ocaml/ocaml/blob/trunk/parsing/parsetree.mli#L145 > > > > What I would like to do is: > > > > | [Rtag the_whole_4_tuple] -> > > the_whole_4_tuple > > > > However, when I try to do that, I am getting: > > > > Error: The constructor Rtag expects 4 argument(s), > > but is applied here to 1 argument(s) > > > > This: > > > > | [Rtag (f1,f2,f3,f4)] -> > > f1,f2,f3,f4 > > > > of course works but (regardless of the chosen bound variable names), it > looks amateurish. > > > > What's the right way to do this? > > (I would like just to bind a 4-tuple and then return it) > > > > (Apologies in advance for a stupid question.) > > > > -- > 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 --f403045fc074cbb30f055be7648f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

I see, where I was wrong. But if the goal is to avoid alloca= tion then something like

[ Rtag (x, y, z, w)] -> somefn x y z w

will work


On Thu, Oct 19, 2017, 17:35= Gabriel Scherer <gabriel.s= cherer@gmail.com> wrote:
Thi= s is a small hiccup with the OCaml (non-revised) syntax:

=C2=A0 | Foo of bar * baz * blah

and

=C2=A0 | Foo of (bar * baz * blah)

are not equivalent, and only the latter allows to do what you want.


On Thu, Oct 19, 2017 at 3:38 PM, Matej Ko=C5=A1=C3=ADk <mail@matej-kosik.net> wrot= e:
> Hi,
>
> I am trying to do simple pattern matching of these values:
> https://github.com/ocaml/oc= aml/blob/trunk/parsing/parsetree.mli#L145
>
> What I would like to do is:
>
>=C2=A0 =C2=A0 | [Rtag the_whole_4_tuple] ->
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 the_whole_4_tuple
>
> However, when I try to do that, I am getting:
>
>=C2=A0 =C2=A0Error: The constructor Rtag expects 4 argument(s),
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 but is applied here to 1 argument(s)=
>
> This:
>
>=C2=A0 =C2=A0 =C2=A0| [Rtag (f1,f2,f3,f4)] ->
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0f1,f2,f3,f4
>
> of course works but (regardless of the chosen bound variable names), i= t looks amateurish.
>
> What's the right way to do this?
> (I would like just to bind a 4-tuple and then return it)
>
> (Apologies in advance for a stupid question.)
>

--
Caml-list mailing list.=C2=A0 Subscription management and archives:
https://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocam= l_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs
--f403045fc074cbb30f055be7648f--