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 LAA16845; Mon, 5 Aug 2002 11:41:16 +0200 (MET DST) 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 LAA16900 for ; Mon, 5 Aug 2002 11:41:15 +0200 (MET DST) Received: from beaune.inria.fr (beaune.inria.fr [128.93.8.3]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g759fEP03244 for ; Mon, 5 Aug 2002 11:41:14 +0200 (MET DST) Received: by beaune.inria.fr (8.8.8/1.1.22.3/14Sep99-0328PM) id LAA0000029449; Mon, 5 Aug 2002 11:41:14 +0200 (MET DST) From: Luc Maranget Message-Id: <200208050941.LAA0000029449@beaune.inria.fr> Subject: Re: [Caml-list] Matching when To: warplayer@free.fr (Nicolas Cannasse) Date: Mon, 5 Aug 2002 11:41:14 +0200 (MET DST) Cc: caml-list@inria.fr (OCaml) In-Reply-To: <000f01c23c62$3ec98150$0700a8c0@warp> from "Nicolas Cannasse" at aoû 05, 2002 11:26:57 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > > Hi ! > > I was thinking that the following should be possible : > > match e with > | Any > | Int x when x > 0 -> > .... (* here we don't use x *) > | .... > > But the typechecker reject it because of the unbound 'x' in the "Any" > matching. > I don't know what kind of difficulty this modification require, but it would > be nice if the compiler was able to resolve such cases. > > :-) > Nicolas Cannasse > Hello, This has already been discussed. The modifications required are important and probably not worth the trouble. More precisely the guard ``when expression'' is not part of patterns but rather part of clauses. That is your example is to to be parsed as Any | Int x <-- pattern \ when x > 0 <-- guard | clause -> | ... <-- right hand side / What you are asking is ``pattern when expression'' to be a pattern. Then your example would be parsed as That is your example is to to be parsed as Any <-- pattern | | | Pattern (or pat) Int x when x > 0 <-- pattern | -> ... <-- right hand side Modifications are really important because this would make patterns and expression mutually recursive, which they are not at the moment. --Luc ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners