From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id CAA24997; Wed, 16 Jul 2003 02:11:13 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 CAA29240 for ; Wed, 16 Jul 2003 02:11:12 +0200 (MET DST) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h6G0Avf09609 for ; Wed, 16 Jul 2003 02:11:00 +0200 (MET DST) Received: from localhost (suiren.kurims.kyoto-u.ac.jp [130.54.16.25]) by kurims.kurims.kyoto-u.ac.jp (8.9.3p2/3.7W) with ESMTP id JAA20775; Wed, 16 Jul 2003 09:10:51 +0900 (JST) To: rich@annexia.org Cc: caml-list@inria.fr Subject: Re: [Caml-list] 'should have type unit' warning in 'let _ =' ? In-Reply-To: <20030715113649.GA5950@redhat.com> References: <20030715100436I.garrigue@kurims.kyoto-u.ac.jp> <20030715113649.GA5950@redhat.com> X-Mailer: Mew version 1.94.2 on Emacs 21.2 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20030716091051K.garrigue@kurims.kyoto-u.ac.jp> Date: Wed, 16 Jul 2003 09:10:51 +0900 From: Jacques Garrigue X-Dispatcher: imput version 20000228(IM140) X-Loop: caml-list@inria.fr X-Spam: no; 0.00; jacques:01 caml-list:01 'let:01 0900,:01 expr:01 enforced:01 garrigue:01 discard:02 unit:03 wrote:03 partial:03 let:04 compiled:05 functions:05 variables:06 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk From: Richard Jones > On Tue, Jul 15, 2003 at 10:04:36AM +0900, Jacques Garrigue wrote: > > By the way, there is a reason "let _ =" produces no warning: this is > > the only way to do a partial application without warning. > > "expr; ..." and even "ignore (expr); ..." will produce a warning. > > Interesting ... what's the use of a partial application which is > then ignored? The same as all application whose result is ignored: side effects. I know this is quite rare. (I can remember using this only once.) But it would be disturbing to make it completely impossible. Or is it not so important? Actually I wonder whether it would not be safer to simply warn for all unused partial applications in a compiled program. This is a bit subtle, as one has to keep track of unused variables too (functions defined by partial application which are never used). A middle ground would be to only warn when the wild pattern matches a function type, assuming that when you name something you know what you are doing. This would be mostly compatible: you just have to name the pattern when you want to discard a function. As a nice aside, it would avoid most uses of "ignore". By the way, my personal approach would be to let programers declare what they want: remove the "should be unit" warning (it can be easily enforced by "let () = ... in"), and remove all warnings on "ignore", since you could then write "let _ = ... in" if you want the partial application warning. But this is maybe expecting too much from programmers. Comments? Jacques Garrigue ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners