From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 2A077BC2F for ; Fri, 26 Nov 2004 10:56:16 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id iAQ9uFfh015265 for ; Fri, 26 Nov 2004 10:56:15 +0100 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 KAA31398 for ; Fri, 26 Nov 2004 10:56:15 +0100 (MET) Received: from smtp3.adl2.internode.on.net (smtp3.adl2.internode.on.net [203.16.214.203]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id iAQ9uCIj015257 for ; Fri, 26 Nov 2004 10:56:14 +0100 Received: from [192.168.1.200] (ppp217-171.lns1.syd3.internode.on.net [203.122.217.171]) by smtp3.adl2.internode.on.net (8.12.9/8.12.9) with ESMTP id iAQ9u4OU056294; Fri, 26 Nov 2004 20:26:04 +1030 (CST) Subject: Re: [Caml-list] Why doesn't ocamlopt detect a missing ; after failwith statement? From: skaller Reply-To: skaller@users.sourceforge.net To: Richard Jones Cc: caml-list In-Reply-To: <20041126090120.GA19749@annexia.org> References: <20041125204628.GA24215@annexia.org> <005701c4d333$c3bc31e0$19b0e152@warp> <20041126090120.GA19749@annexia.org> Content-Type: text/plain Message-Id: <1101462963.9291.325.camel@pelican.wigram> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 26 Nov 2004 20:56:03 +1100 Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 41A6FDBF.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 41A6FDBC.002 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 ocamlopt:01 failwith:01 sourceforge:01 wrote:01 ocaml:01 exn:01 silently:01 conditionals:01 syntax:01 foo:01 lalr:01 unambiguous:01 val:01 ocaml:01 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.0 X-Spam-Level: On Fri, 2004-11-26 at 20:01, Richard Jones wrote: > Thanks everyone for the explanation, and the rather convoluted > discussion of the type system, which I don't really understand. > > I'd just like to add that this error bit me in a real program, and it > would be nice if OCaml detected this common case and warned about it: > > if cond then ( > ... > raise Exn > ) > next_stmt <-- catastrophic failure, because this statement > is silently ignored This happens too, and seems harder to catch with the intertwined procedural/functional coding style: if cond then x .. y ... <-- woops, executed unconditionally ; next In Felix I do this: if cond then something else something_else endif; where the 'else' and 'endif' are both mandatory. For procedural conditionals I have distinct syntax: if cond do foo; bah; done; Both constructions are LALR1 and unambiguous. Note the if/then/else/endif is purely functional, the displayed statement is equivalent to val f: unit -> void = if cond then something else something_else endif ; f(); The ocaml notation is more compact but less safe. Camlp4 could fix this I think, perhaps the revised syntax already does? -- John Skaller, mailto:skaller@users.sf.net voice: 061-2-9660-0850, snail: PO BOX 401 Glebe NSW 2037 Australia Checkout the Felix programming language http://felix.sf.net