From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 23919BB84 for ; Wed, 13 Aug 2008 12:13:57 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AioBANhPokjC2fJYomdsb2JhbACJMYhFAQEBAQEBBwUGCRGlCoFV X-IronPort-AV: E=Sophos;i="4.32,201,1217800800"; d="scan'208";a="15961985" Received: from anchor-post-30.mail.demon.net ([194.217.242.88]) by mail3-smtp-sop.national.inria.fr with ESMTP; 13 Aug 2008 12:13:56 +0200 Received: from orion.metastack.com ([80.177.38.218]) by anchor-post-30.mail.demon.net with esmtp (Exim 4.67) id 1KTDMa-000KOO-0o for caml-list@yquem.inria.fr; Wed, 13 Aug 2008 10:13:56 +0000 Received: from orion.metastack.com (IDENT:25@localhost [127.0.0.1]) by orion.metastack.com (8.13.4/8.13.3) with ESMTP id m7D9sOO4013160 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 13 Aug 2008 10:55:08 +0100 Received: (from defang@localhost) by orion.metastack.com (8.13.4/8.13.3/Submit) id m7D9cN4O013066 for ; Wed, 13 Aug 2008 10:38:23 +0100 X-Authentication-Warning: orion.metastack.com: defang set sender to using -f Received: from countertenor (cpc1-cmbg10-0-0-cust76.cmbg.cable.ntl.com [81.102.132.77]) by orion.metastack.com (envelope-sender ) (MIMEDefang) with ESMTP id m7D9cMuM013064; Wed, 13 Aug 2008 10:38:23 +0100 (BST) From: "David Allsopp" To: "'Brighten Godfrey'" Cc: "'OCaml List'" References: <9E2C98C8798A487DAE77F20A9DC4F1E8@countertenor> <7C6C7ADD-910D-4C62-92FF-E286F0817FA1@cs.berkeley.edu> Subject: RE: [Caml-list] Value shadowing Date: Wed, 13 Aug 2008 10:56:53 +0100 Organization: MetaStack Solutions Ltd. Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 11 Thread-Index: Acj9Ipwe4gchqqwOQGeY34Hab4x/wAAB1v+A X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5512 In-Reply-To: <7C6C7ADD-910D-4C62-92FF-E286F0817FA1@cs.berkeley.edu> X-Scanned-By: MIMEDefang 2.63 on 80.177.38.218 X-Spam: no; 0.00; caml-list:01 let:03 let:03 style:93 style:93 cases:08 cases:08 function:08 fun:08 fun:08 useful:09 useful:09 recall:10 although:11 becomes:11 > > a useful style and would be greatly irritated by a warning on all > > shadowing > > - but I think that in most cases for me the type of each [x] is > > different. > > I also find that style useful. Sometimes the type changes, but I can > recall useful cases where the type doesn't change, e.g., a sequence > of various operations on a list. Mock-up: > > let lst = generate_list_somehow () in > let lst = List.filter (fun x -> x > 0) in > let lst = List.sort compare lst in > ... Although in this case you can use a function composition operator instead - so let lst = [5; 4; 3; 2; 1; 0; -1; -2; -3; -4; -5] in let lst = List.filter (fun x -> x > 0) lst in let lst = List.map (fun x -> -2 * x) lst in let lst = List.sort compare lst in lst becomes [assuming let ($$) f g x = f (g x)] let lst = [5; 4; 3; 2; 1; 0; -1; -2; -3; -4; -5] in let filter = List.filter (fun x -> x > 0) in let double = List.map (fun x -> -2 * x) in let sort = List.sort compare in (sort $$ double $$ filter) lst David