From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: weis Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id TAA21322 for caml-redistribution; Fri, 19 Feb 1999 19:33:05 +0100 (MET) 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 TAA01781 for ; Fri, 19 Feb 1999 19:32:54 +0100 (MET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.8.7/8.8.7) with ESMTP id TAA24761; Fri, 19 Feb 1999 19:32:46 +0100 (MET) Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id TAA23736; Fri, 19 Feb 1999 19:32:46 +0100 (MET) From: Pierre Weis Message-Id: <199902191832.TAA23736@pauillac.inria.fr> Subject: Re: Warnings in ocaml To: garrigue@kurims.kyoto-u.ac.jp (Jacques GARRIGUE) Date: Fri, 19 Feb 1999 19:32:46 +0100 (MET) Cc: caml-list@inria.fr In-Reply-To: <19990219213015B.garrigue@kurims.kyoto-u.ac.jp> from "Jacques GARRIGUE" at Feb 19, 99 09:30:15 pm X-Mailer: ELM [version 2.4 PL24 ME8] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: weis > * having a warning when a function doesn't return unit in a sequence > may catch some bugs, but this is a pain with imperative programming > style, where you may not be interested by the result of a function but > just by its side-effects. Could you please give me some interesting examples (Yes, I know you can write this kind of functions, but I would like some examples where it seems really painful to work it out otherwise). Furthermore the point here is that this warning is useful, since we had 2 undetected bugs into the Objective Caml system due to the lack of this warning. > Of course you can switch off the warning, > but I'm not sure having it on is a good default, since the default > mode should be normative. The Caml system example shows that this warning is useful, even for the most experienced programmers, let alone the beginners that do not know how to get the warning on if they know that it exists... > ex. wrong code > x = 3; ... > ^ should be <- Or even x := 3. > ex. right code > f x y; ... > where f: t1 -> t2 -> int has some interesting side-effect. In this case the warning tells you that you may be have a further look to your f function: is it necessary to mix side effects and purely functional computation ? Very often, this is not necessary and rewriting the code to avoid the mixing gets it clearer. If it is not the case, you can tell it to the reader and write let _ = f x y in ... > * another common error with imperative code is partial application in > a toplevel call inside a module > > let _ = > somefunc hsj hjfhfd > > somefunc takes 3 arguments but is only given 2. Since this is a > let-definition no warning is printed while such a partial application > is pretty meaningless. > > Regards, > > Jacques > --------------------------------------------------------------------------- > Jacques Garrigue Kyoto University garrigue at kurims.kyoto-u.ac.jp > JG So you want another warning for dummy definitions at the toplevel of modules when the application if partial ? Or may be you want to extend the sequence warning to this case when the result is not unit ? Best regards, Pierre Weis INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://cristal.inria.fr/~weis/