caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "vrotaru.md@gmail.com" <vrotaru.md@gmail.com>
To: Gabriel Scherer <gabriel.scherer@gmail.com>
Cc: "Matej Košík" <mail@matej-kosik.net>, "caml users" <caml-list@inria.fr>
Subject: Re: [Caml-list] beginner question about pattern matching
Date: Thu, 19 Oct 2017 14:44:19 +0000	[thread overview]
Message-ID: <CAJgjwehgdAaSLWa=D+crmiA9GB1sBqp9_+GN1sARGxh06c26Og@mail.gmail.com> (raw)
In-Reply-To: <CAPFanBF3DXnpOPOjZyKQnHRQR_9gmzqn=woawJ_F5MdkUqm8Sg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1551 bytes --]

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 <gabriel.scherer@gmail.com>
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šík <mail@matej-kosik.net> 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

[-- Attachment #2: Type: text/html, Size: 2476 bytes --]

      parent reply	other threads:[~2017-10-19 14:44 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-19 13:38 Matej Košík
2017-10-19 14:16 ` vrotaru.md
2017-10-19 14:24   ` Matej Košík
2017-10-19 14:29     ` vrotaru.md
2017-10-19 14:30       ` Olivier Nicole
2017-10-19 14:31     ` Alan Schmitt
2017-10-19 14:34 ` Gabriel Scherer
2017-10-19 14:40   ` Matej Košík
2017-10-19 14:44   ` vrotaru.md [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAJgjwehgdAaSLWa=D+crmiA9GB1sBqp9_+GN1sARGxh06c26Og@mail.gmail.com' \
    --to=vrotaru.md@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=gabriel.scherer@gmail.com \
    --cc=mail@matej-kosik.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).