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 B65B5BC92 for ; Mon, 29 Nov 2004 01:40:51 +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 iAT0epoD014765 for ; Mon, 29 Nov 2004 01:40:51 +0100 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 BAA04004 for ; Mon, 29 Nov 2004 01:40:50 +0100 (MET) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id iAT0enr0001400; Mon, 29 Nov 2004 01:40:50 +0100 Received: from localhost (suiren [130.54.16.25]) by kurims.kurims.kyoto-u.ac.jp (8.13.1/8.13.1) with ESMTP id iAT0el2E021875; Mon, 29 Nov 2004 09:40:48 +0900 (JST) Date: Mon, 29 Nov 2004 09:40:35 +0900 (JST) Message-Id: <20041129.094035.02308731.garrigue@math.nagoya-u.ac.jp> To: damien.doligez@inria.fr Cc: caml-list@inria.fr Subject: Re: [Caml-list] Why doesn't ocamlopt detect a missing ; after failwith statement? From: Jacques Garrigue In-Reply-To: References: <1101438486.9291.138.camel@pelican.wigram> <20041126.142525.93385094.garrigue@math.nagoya-u.ac.jp> X-Mailer: Mew version 4.0.64 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 41AA7013.002 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 41AA7011.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 ocamlopt:01 failwith:01 damien:01 damien:01 failwith:01 forall:01 foo:01 foo:01 inference:01 annotation:01 compiler:01 foolproof:98 doligez:01 doligez: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: From: Damien Doligez > > I believe the problem with failwith is solvable, albeit rather > > complicated. The idea is that you want to be warned when you apply a > > function of type (\forall 'a. 'a) to something, because no such > > function may exist, so that this application will never actually take > > place. > > More generally, you want to output a warning whenever the computation > of such a value is not immediately followed by a join in the control > flow graph, because at that point you know you're compiling dead code. > > Then you would also get a warning for things like this: > > failwith "foo"; > print_string "hello world" > > or > > f (a, b, failwith "foo", c, d) > > etc. > > Don't ask me to implement it, though. This is not specially hard to implement case by case. The problem is rather that the technique I use, based on type inference, is not foolproof (you can avoid the warning with a type annotation for instance) and is wrong in presence of Obj.magic. So the question is in which cases having a warning is worth the inconvenience and the extra code in the compiler. I would say your first example is reasonable (this may be a consequence of a dangling then), but much less the second one (where is the ambiguity?) Jacques Garrigue