From: Luc Maranget <luc.maranget@inria.fr>
To: pixel@mandrakesoft.com (Pixel)
Cc: caml-list@pauillac.inria.fr
Subject: Re: [Caml-list] "Or" patterns when both matchings
Date: Mon, 29 Oct 2001 11:37:58 +0100 (MET) [thread overview]
Message-ID: <200110291037.LAA0000013411@beaune.inria.fr> (raw)
In-Reply-To: <ly3d44yqmt.fsf@leia.mandrakesoft.com> from "Pixel" at oct 28, 2001 12:02:02
>
>
> from the documentation:
> The pattern pattern1 | pattern2 represents the logical ``or'' of the two
> patterns pattern1 and pattern2. [...] If both matchings succeed, it is
> undefined which set of bindings is selected.
>
> is there a reason for not using the classical pattern matching rule, to make
> the ordering matters? (i've been nastily beat by this :-/)
>
> eg:
>
>
> type foo = Bar | Foo of foo
>
> let f1 = function
> | Foo(a)
> | a -> a
>
> let f2 = function
> | Foo(a) -> a
> | a -> a
>
> let e1 = f1 (Foo Bar) (*=> Foo Bar *)
> let e2 = f2 (Foo Bar) (*=> Bar *)
>
>
> thanks
> --
> Pixel
Yes there are two reasons
1. ease of compilation.
As you have experienced yourself. In case one of the patterns in
the or-pattern is a variable, then the or-pattern is reduced to a
variable. Otherwise, compilation would be a bit more complicated.
2. Ideology. I consider that priority in or-patterns is something
obscure, and would discourage relying on it.
However the current (unspecified) semantics makes the idea
of a ``partially useless'' matching clause a bit random, and this
semantics may become more precise in the future.
Cheers,
--Luc
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
next prev parent reply other threads:[~2001-10-29 10:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-10-28 11:02 Pixel
2001-10-29 10:37 ` Luc Maranget [this message]
2001-10-30 18:22 Manuel Fahndrich
2001-10-31 9:42 ` Luc Maranget
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=200110291037.LAA0000013411@beaune.inria.fr \
--to=luc.maranget@inria.fr \
--cc=caml-list@pauillac.inria.fr \
--cc=pixel@mandrakesoft.com \
/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