Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Luc Maranget <luc.maranget@inria.fr>
To: pixel@mandrakesoft.com (Pixel)
Cc: FernandezPons@iFrance.com (Diego Olivier Fernandez Pons),
	caml-list@inria.fr (Caml)
Subject: Re: [Caml-list] Pattern matching
Date: Fri, 9 Nov 2001 11:59:17 +0100 (MET)	[thread overview]
Message-ID: <200111091059.LAA0000000130@beaune.inria.fr> (raw)
In-Reply-To: <lyeln8hjqx.fsf@leia.mandrakesoft.com> from "Pixel" at nov 09, 2001 01:26:46

About pattern matching.
> 
> "Diego Olivier Fernandez Pons" <FernandezPons@iFrance.com> writes:
is right to stress on the fact that variables in patterns are
binding variables, some variable is bound to something.
when you write

let x = ex in
let x = ex' in

You certainly do not mean that ex and ex' are equal (whatever it
means).



On linearity :

> 
> > let egalite = function
> >    | (x,x) -> true
> >    | (x,y) -> false
> > ;;
> > # This variable is bound several times in this matching
> 
> i wonder why this one is not allowed since it can't have any other meaning
> than the one it has in prolog. What's the reason for not having it rewritten
> to:
> 

Does not mean :

> > let egalite = function
> >    | (x,x') when x=x' -> true
> >    | (x,y) -> false
> 

Well, it could be that way. But it is not.

This can be argueed as follows.

  As already said the meaning of (x,x) is not clear, should we use
  ``='' (and then pattern matching may last for ever, or may raise
  an exception (for functions)) or ``=='' (and this is not very useful).

  Futhermore the theory of non-left-linear rewriting is more
  complicated than the one of left-linear rewriting and this theory
  somehow applies to ML pattern matching.


So my opinion is that non-linear pattern brings little benefits to
users, complicates much the life of the compiler writer and may even
introduce subtle bugs in users programs.


--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


  reply	other threads:[~2001-11-09 10:59 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-11-08  2:33 Diego Olivier Fernandez Pons
2001-11-09  0:26 ` Pixel
2001-11-09 10:59   ` Luc Maranget [this message]
     [not found] ` <15339.34220.198731.791811@lachesis.inria.fr>
2001-11-10  2:16   ` Diego Olivier Fernandez Pons
2001-11-12 10:29     ` Luc Maranget
2001-11-12  9:00       ` Diego Olivier Fernandez Pons
2001-11-13  8:00         ` Fabrice Le Fessant
2001-11-13 23:57           ` [Caml-list] If ou Pattern-matching ? Diego Olivier Fernandez Pons
2001-11-14 10:02             ` Fabrice Le Fessant
2001-11-14 10:47             ` Nicolas Barnier
2001-11-14  1:26               ` [Caml-list] Warnings possibles Diego Olivier Fernandez Pons
2001-11-14 18:24                 ` Luc Maranget
2001-11-14 11:35             ` [Caml-list] If ou Pattern-matching ? Luc Maranget
2001-11-13 16:09         ` [Caml-list] Pattern matching Luc Maranget
2001-11-13 23:56           ` [Caml-list] Deux types de pattern-matching ? Diego Olivier Fernandez Pons
2001-11-14 10:19             ` [Caml-list] " 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=200111091059.LAA0000000130@beaune.inria.fr \
    --to=luc.maranget@inria.fr \
    --cc=FernandezPons@iFrance.com \
    --cc=caml-list@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