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 VAA17875; Thu, 18 Jul 2002 21:27:21 +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 VAA17870 for ; Thu, 18 Jul 2002 21:27:20 +0200 (MET DST) Received: from fort-point-station.mit.edu (FORT-POINT-STATION.MIT.EDU [18.7.7.76]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g6IJRJT12866 for ; Thu, 18 Jul 2002 21:27:19 +0200 (MET DST) Received: from central-city-carrier-station.mit.edu (CENTRAL-CITY-CARRIER-STATION.MIT.EDU [18.7.7.72]) by fort-point-station.mit.edu (8.9.2/8.9.2) with ESMTP id PAA29934 for ; Thu, 18 Jul 2002 15:27:18 -0400 (EDT) Received: from melbourne-city-street.mit.edu (MELBOURNE-CITY-STREET.MIT.EDU [18.7.21.86]) by central-city-carrier-station.mit.edu (8.9.2/8.9.2) with ESMTP id PAA05257 for ; Thu, 18 Jul 2002 15:27:17 -0400 (EDT) Received: from psi-phi.mit.edu (PSI-PHI.MIT.EDU [18.187.1.35]) by melbourne-city-street.mit.edu (8.9.2/8.9.2) with ESMTP id PAA14047 for ; Thu, 18 Jul 2002 15:27:17 -0400 (EDT) Received: (from jfc@localhost) by psi-phi.mit.edu (8.9.3) id PAA18741; Thu, 18 Jul 2002 15:27:16 -0400 Message-Id: <200207181927.PAA18741@psi-phi.mit.edu> To: caml-list@inria.fr Subject: [Caml-list] syntax question -- end of pattern-matching Date: Thu, 18 Jul 2002 15:27:16 -0400 From: John Carr 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" I am unable to figure out from the grammar why this is so. If the section 6.7 of the manual is correct, an expression may not be empty so two semicolons separated by whitespace should not be allowed. Thus the second form of the definition should cause a syntax error. If an empty expression were allowed, the second form would be parsed like the first, with "hello" as part of the expression sequence in the "with" clause. Is it possible to deduce ocaml's behavior from the grammar? --John Carr (jfc@mit.edu) ------------------- 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