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 TAA02031; Tue, 1 Jun 2004 19:31:56 +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 TAA06397 for ; Tue, 1 Jun 2004 19:31:55 +0200 (MET DST) Received: from ptb-relay02.plus.net (ptb-relay02.plus.net [212.159.14.213]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i51HVrSH025441 for ; Tue, 1 Jun 2004 19:31:54 +0200 Received: from [80.229.56.224] (helo=chetara) by ptb-relay02.plus.net with esmtp (Exim) id 1BVD7A-000PL9-LW for caml-list@inria.fr; Tue, 01 Jun 2004 17:31:52 +0000 From: Jon Harrop Organization: University of Cambridge To: caml-list@inria.fr Subject: Re: [Caml-list] Strange syntax behavior Date: Tue, 1 Jun 2004 18:30:32 +0100 User-Agent: KMail/1.6.2 References: <20040601171354.GA16495@excelhustler.com> In-Reply-To: <20040601171354.GA16495@excelhustler.com> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200406011830.32881.jdh30@cam.ac.uk> X-Miltered: at concorde with ID 40BCBD89.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 bug:01 misleading:01 indentation:01 compiler:01 emacs:01 syntax:02 match:02 match:02 behavior:03 behavior:03 brackets:95 seems:05 meant:05 meant:05 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > In the case of if...then...else, the else clause appears to consume only > the first statement following. Yes, it is looking for an expression: if true then p "yes" else p "no"; p "done";; You may have meant: if true then p "yes" else begin p "no"; p "done" end;; > With try..with, the with clause appears > to consume everything it possibly can, despite even attempts to stop > that with a begin..end clause. Yes, it is looking for pattern matches. try p "test" with Not_found -> begin p "exc"; end; p "done";; You probably meant: begin try p "test" with Not_found -> p "exc"; end; p "done";; > Is this a bug or a feature? If a feature, why is this so? the > try..with behavior seems highly misleading. I got a feeling for how these sorts of things work by looking at the indentation style (in emacs). It's fairly obvious that pattern matches (including "try ... with ..." as well as just "match ... with ...") need either brackets or "begin ... end" to nest them as, without this, the compiler couldn't tell which pattern was matching which match. Cheers, Jon. ------------------- 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