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 DAA22104; Tue, 15 Jul 2003 03:04:49 +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 DAA21989 for ; Tue, 15 Jul 2003 03:04:47 +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 h6F14jf21019 for ; Tue, 15 Jul 2003 03:04:46 +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 KAA08487; Tue, 15 Jul 2003 10:04:37 +0900 (JST) To: henridf@lcavsun1.epfl.ch Cc: caml-list@inria.fr Subject: Re: [Caml-list] 'should have type unit' warning in 'let _ =' ? In-Reply-To: References: 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: <20030715100436I.garrigue@kurims.kyoto-u.ac.jp> Date: Tue, 15 Jul 2003 10:04:36 +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 henridf:01 lcavsun:01 bug:01 advocating:01 expr:01 garrigue:01 lazy:02 module:03 unit:03 suppose:03 partial:03 let:04 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk From: henridf@lcavsun1.epfl.ch > i had a minor bug where the last expression in a > let _ = ... > block of my module was not fully applied and hence was returning a > functional value rather than apply the function (because I had added a > parameter to the function). > > pretty harmless, but it led me to wonder why I wasn't writing 'let () = > ..' for all my module initialization blocks, which would have given me > 'warning should have type unit' in the above situation. > > So is there a reason why the commonly used idiom seems to be 'let _ =' > rather than 'let () = '? I suppose this is the 1 character difference :-) Programmers are lazy. I've been advocating using "let () =" for a while now, and I am of course using it myself. 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. By the way, I'm always disabling the s warning ("should be unit"), to avoid being tempted by using "let _ = expr in " when I want to ignore the result of a fully applied expression which does not return unit. I know ignore does it, but I'm lazy too. Jacques ------------------- 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