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=AWL autolearn=disabled version=3.1.3 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 52559BB84 for ; Wed, 13 Aug 2008 13:04:23 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApoEAIBcokjUVZsV/2dsb2JhbAC3OoFV X-IronPort-AV: E=Sophos;i="4.32,201,1217800800"; d="scan'208";a="16082086" Received: from cerberus.snarc.org ([212.85.155.21]) by mail1-smtp-roc.national.inria.fr with ESMTP; 13 Aug 2008 13:04:23 +0200 Received: by cerberus.snarc.org (Postfix, from userid 1000) id 5CA2D129E8; Wed, 13 Aug 2008 12:05:46 +0100 (BST) Date: Wed, 13 Aug 2008 12:05:46 +0100 From: Vincent Hanquez To: Brighten Godfrey Cc: David Allsopp , OCaml List Subject: Re: [Caml-list] Value shadowing (tangent) Message-ID: <20080813110546.GA22672@snarc.org> References: <9E2C98C8798A487DAE77F20A9DC4F1E8@countertenor> <7C6C7ADD-910D-4C62-92FF-E286F0817FA1@cs.berkeley.edu> <1C96BA4C-8E65-44AA-96CD-C1CA399635E2@cs.berkeley.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1C96BA4C-8E65-44AA-96CD-C1CA399635E2@cs.berkeley.edu> X-Warning: Email may contain unsmilyfied humor and/or satire. User-Agent: Mutt/1.5.18 (2008-05-17) X-Spam: no; 0.00; ocaml:01 wrote:01 wrote:01 readable:01 readable:01 caml-list:01 let:03 let:03 scope:04 scope:04 wed:06 vincent:07 vincent:07 fun:08 fun:08 On Wed, Aug 13, 2008 at 03:49:23AM -0700, Brighten Godfrey wrote: > Going off on a tangent here... > > On Aug 13, 2008, at 2:56 AM, David Allsopp wrote: >> >> 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 > > I've seen little of other people's OCaml code, so out of curiosity, do > you or others actually write code formatted like the above, as opposed to > the more compact and (I think) readable > > 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 I write the compact way too, which i found much more readable. I really dislike the wavy effect, of the former example, it has on code. however i understand why some people do it the first way. after the "in" you're in some sort of new scope (previous scope augmented by your let binds) -- Vincent