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