Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Martin Jambon <martin1977@laposte.net>
To: taras <taras.judge@shaw.ca>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Pattern matching fallthrough with guards
Date: Tue, 28 Nov 2006 11:53:21 -0800 (PST)	[thread overview]
Message-ID: <Pine.LNX.4.58.0611281144350.16862@localhost> (raw)
In-Reply-To: <456C8774.4040009@shaw.ca>

On Tue, 28 Nov 2006, taras wrote:

> Hi,
> I noticed that one can coalesce multiple patterns like
>
> function Some _
>      | None -> 0
>
> However when I add guards to this hypothetical example, I get a syntax error
>
> function Some _ when 1 = 2
>     |  None -> 0
>
> I'm wondering if this inconsistency is considered to be a bug or not?

It's not a bug.
The "when" guard must come just before the arrow.
But the vertical bar may be more powerful than what you expect. You can do
this:

function Some (0|1) | None -> ...
       | ...

Martin

--
Martin Jambon, PhD
http://martin.jambon.free.fr


      reply	other threads:[~2006-11-28 19:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-28 19:01 taras
2006-11-28 19:53 ` Martin Jambon [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=Pine.LNX.4.58.0611281144350.16862@localhost \
    --to=martin1977@laposte.net \
    --cc=caml-list@inria.fr \
    --cc=taras.judge@shaw.ca \
    /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