From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p7UNePBP014515 for ; Wed, 31 Aug 2011 01:40:25 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqgBAL10XU7RVdivkGdsb2JhbABCmRyPHwgUAQEBAQkJDQcUBCGBQAEBAQECARICExkBOQMBCwEFBQsNLiISAQUBCxEZIodQmlQKjxCFJ4koAgMGhk4Ei32HKIxhPIFHgiM X-IronPort-AV: E=Sophos;i="4.68,304,1312149600"; d="scan'208";a="117768308" Received: from mail-qy0-f175.google.com ([209.85.216.175]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 31 Aug 2011 01:40:18 +0200 Received: by qyk4 with SMTP id 4so3220212qyk.6 for ; Tue, 30 Aug 2011 16:40:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; bh=RzLttnXHA7KrJ2eOmIoFevnahCy29eCSRK+ROSGSmik=; b=arF4WpA82RfML1i8JrWyQfSTpJ4/9ZF/j6auwVoBG755y/+FVggfiovrsSPQncZJ47 sGVjx5rTVKUzYZ9RMFEzFLYxnjS+t0Dfu2GmmKJLw89i8oA16aEL+zyAJ3dz2umSbvjY PtAbWJdrrVqIJMXpiKRjgpn6tlImPZs06clT8= MIME-Version: 1.0 Received: by 10.224.200.202 with SMTP id ex10mr3330246qab.40.1314747617209; Tue, 30 Aug 2011 16:40:17 -0700 (PDT) Sender: philippe.wang.lists@gmail.com Received: by 10.224.89.19 with HTTP; Tue, 30 Aug 2011 16:40:17 -0700 (PDT) In-Reply-To: <201108302231.p7UMVvoB024895@outgoing.mit.edu> References: <20110830132737.78b7a08e@lri.fr> <201108302231.p7UMVvoB024895@outgoing.mit.edu> Date: Wed, 31 Aug 2011 01:40:17 +0200 X-Google-Sender-Auth: fYtbK_FDN7Bf0bximlBF7wsL_Us Message-ID: From: Philippe Wang To: caml-list@inria.fr Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id p7UNePBP014515 Subject: Re: [Caml-list]Warning 20: this argument will not be used by the function. On Wed, Aug 31, 2011 at 12:31 AM, John Carr wrote: > # let f () = assert false; 0;; > Warning 21: this statement never returns (or has an unsound type.) > val f : unit -> int = > Assert behaves like a function with type bool -> 'a.  The return type is > an unconstrained type, a type variable not mentioned on the left hand > side of the arrow. Actually, assert is more like a function with type bool -> unit. Indeed, (assert false) is a special case where it is "so obvious that it'll raise an exception that it's made type 'a". Notably, if you write assert(1=2) it's not "obvious enough" for the compiler to assume it will raise an exception. (Which is normal, by the way, because it's generally an undecidable problem: in general, it's not possible to know that the evaluation of assert's argument will return a value, especially when there is a function application such as in "1=2".) So, in let f () = assert false f : unit -> 'a let f () = assert (1=2) f : unit -> unit And while let f () = assert false; 0;; raises a warning, let f () = assert (1=2); 0;; won't raise any. Somehow, the choice of discriminating (assert false) is not so perfect... Cheers, -- Philippe Wang N.B. Sorry for double-replying. I wonder if "reply-to: caml-list@inria.fr" field could be added automatically to headers of all mails received by the list...