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 OAA32634; Fri, 19 Jul 2002 14:00:30 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id OAA32630 for ; Fri, 19 Jul 2002 14:00:29 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g6JC0Rv09593; Fri, 19 Jul 2002 14:00:27 +0200 (MET DST) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id OAA32626; Fri, 19 Jul 2002 14:00:27 +0200 (MET DST) Date: Fri, 19 Jul 2002 14:00:26 +0200 From: Xavier Leroy To: John Carr Cc: caml-list@inria.fr Subject: Re: [Caml-list] syntax question -- end of pattern-matching Message-ID: <20020719140026.A32590@pauillac.inria.fr> References: <200207181927.PAA18741@psi-phi.mit.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: <200207181927.PAA18741@psi-phi.mit.edu>; from jfc@MIT.EDU on Thu, Jul 18, 2002 at 03:27:16PM -0400 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > If I write a match directly within another match, or a try ... with > expression in a sequence of expressions, it is often necessary to > use two semicolons separated by whitespace after the pattern matching. > > For example, > > let f x = try x + 1 with Invalid_argument _ -> 42 ; "hello" > > is parsed as > > let f x = try x + 1 with Invalid_argument _ -> (42 ; "hello") > > (and causes a type error), but if I add a second semicolon > > let f x = try x + 1 with Invalid_argument _ -> 42 ; ; "hello" > > is parsed as > > let f x = (try x + 1 with Invalid_argument _ -> 42;) ; "hello" Please don't use the "; ;" form: it has never been intended to work, it's just an unexpected consequence of some other decisions made in the Yacc grammar. The proper way to write what you want is let f x = (try x + 1 with Invalid_argument _ -> 42) ; "hello" or let f x = begin try x + 1 with Invalid_argument _ -> 42 end; "hello" - Xavier Leroy ------------------- 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