From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr 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 47C2DBB81 for ; Thu, 8 Dec 2005 08:12:11 +0100 (CET) Received: from smtp1.adl2.internode.on.net (smtp1.adl2.internode.on.net [203.16.214.181]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id jB87C9LE016714 for ; Thu, 8 Dec 2005 08:12:10 +0100 Received: from rosella (ppp33-4.lns1.syd2.internode.on.net [59.167.33.4] (may be forged)) by smtp1.adl2.internode.on.net (8.12.9/8.12.6) with ESMTP id jB87BogG079034; Thu, 8 Dec 2005 17:41:51 +1030 (CST) (envelope-from skaller@users.sourceforge.net) Subject: Re: [Caml-list] partial application warning unreliable? From: skaller To: Jacques Garrigue Cc: caml-list@yquem.inria.fr In-Reply-To: <20051208.121012.49167263.garrigue@math.nagoya-u.ac.jp> References: <1134009551.10435.24.camel@rosella> <20051208.121012.49167263.garrigue@math.nagoya-u.ac.jp> Content-Type: text/plain Date: Thu, 08 Dec 2005 18:11:49 +1100 Message-Id: <1134025910.8948.44.camel@rosella> Mime-Version: 1.0 X-Mailer: Evolution 2.4.1 Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 4397DCC9.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 srcref:01 token:01 srcref:01 bug:01 semicolon:01 trailing:01 semicolon:01 camlp:01 parser:01 grammar:01 rhs:01 expr:01 ocaml:01 bug:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 On Thu, 2005-12-08 at 12:10 +0900, Jacques Garrigue wrote: > From: skaller > > > method add_nonterminal (s:string) (sr:range_srcref) (toks: > > Flx_parse.token list) (term:ast_term_t) = > > > > ... > > state#add_nonterminal tok (Flx_srcref.slift sr) t; > > > > Method has 4 arguments, but the call applies to only 3. > > > > Woops, no warning!! Bad! This error of mine caused a serious > > bug -- the method call didn't do anything! > > Wait a minute, is there anything after the semicolon? yes, it is followed by an empty list [] > The point is that a trailing semicolon at the end of a method > definition does nothing: it still returns the result of the previous > expression! That's a bit weird, but I guess the decision is somewhat arbitrary .. I actually wonder if using camlp4 changes this result (since I guess it is an artefact of the parser/grammar rather than a deliberate choice .. :) > I wonder whether this behaviour is good or not, but this also means > that there is no reason to have a warning here. IMHO an expression on the LHS of a semicolon expression (possibly excluding the degenerate case the RHS is empty) should have type unit**, and it should be *hard error* not a warning if it doesn't: the ignore(expr) function can be used to suppress the error if required. ** as you know I think the type should be void, not unit. Other systems (such as FISh) has a special type such as 'command' for this. But whichever type is chosen, Ocaml should be *strict* about it. It is strict everywhere else .. I don't understand why it isn't strict here. > If there is an expression after the semicolon, and you have no > warning, then file a bug report: the type system is supposed to detect > all partial applications in statements, except for functions whose > result is a polymorphic type variable. I don't have a reduced example though, and the error is already fixed in my code. > By the way, your other example with classes is wrong: > > # class cc = object (self) > method f x y = x + y > method g () = self#f 1; > end;; > class cc : > object method f : int -> int -> int method g : unit -> int -> int end > > No warning, for the reason stated above: the semicolon does nothing. Ouch .. you're right -- I actually DID get an error F .. jumbled up inside THREE copies of the text the top level printed trying to underline the error. The toplevel is very sick .. BTW: the error flags documentation is very confusing: A/a enable/disable all warnings X/x enable/disable all other warnings other than what? I am using -w yz but STILL get warning X, unused function argument .. some of this happens in Frontc/CIL which I'm using and I would like to minimise patches. BTW: what is this for? S/s enable/disable non-unit statement Isn't that going to be F partial application 99% of the time? If I turn off F, will I get S instead? -- John Skaller Felix, successor to C++: http://felix.sf.net