From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA09147; Fri, 9 Nov 2001 11:59:24 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id LAA09702 for ; Fri, 9 Nov 2001 11:59:23 +0100 (MET) Received: from beaune.inria.fr (beaune.inria.fr [128.93.8.3]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id fA9AxNn04572 for ; Fri, 9 Nov 2001 11:59:23 +0100 (MET) Received: by beaune.inria.fr (8.8.8/1.1.22.3/14Sep99-0328PM) id LAA0000000130; Fri, 9 Nov 2001 11:59:17 +0100 (MET) From: Luc Maranget Message-Id: <200111091059.LAA0000000130@beaune.inria.fr> Subject: Re: [Caml-list] Pattern matching To: pixel@mandrakesoft.com (Pixel) Date: Fri, 9 Nov 2001 11:59:17 +0100 (MET) Cc: FernandezPons@iFrance.com (Diego Olivier Fernandez Pons), caml-list@inria.fr (Caml) In-Reply-To: from "Pixel" at nov 09, 2001 01:26:46 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk About pattern matching. > > "Diego Olivier Fernandez Pons" 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