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 q05KRUWt003887 for ; Thu, 5 Jan 2012 21:27:30 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AokDAB8HBk/RVdK2kWdsb2JhbABCggWaPYghAYgSCCIBAQEBCQkNBxIngXIBAQEDARICLAEbEAIIAwEDAQsGBQQHDQ0hIQEBEQEFAQoSBhMSEIdYCJk4Cotngm+EWD+IcQIFC4NyiBQEgluSK4pwgw49g3o X-IronPort-AV: E=Sophos;i="4.71,464,1320620400"; d="scan'208";a="138039966" Received: from mail-iy0-f182.google.com ([209.85.210.182]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 05 Jan 2012 21:27:26 +0100 Received: by iadj38 with SMTP id j38so2191610iad.27 for ; Thu, 05 Jan 2012 12:27:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=s1ZwtwXR0sT4aQeD/tbuBkiUa4a5sDulmZPcuMsv0yU=; b=PZEjciSGpgTLDCC5AU+oA1kuOjYkue8+HTTzt4rwqI3HwbJby5fEIzJ3WPMatObEG6 J88vBB//7J8D8X/0nH2ODzfHAs77fnTFuNor8180pgniEJhCM/pA0cRGUpGwHqhvruh1 1enO/wuwABLcXoiO27sfWdxPiCPqtUvZPSHZE= MIME-Version: 1.0 Received: by 10.42.76.66 with SMTP id d2mr3564086ick.7.1325795245104; Thu, 05 Jan 2012 12:27:25 -0800 (PST) Received: by 10.42.163.3 with HTTP; Thu, 5 Jan 2012 12:27:25 -0800 (PST) In-Reply-To: <20120105200442.GA17669@annexia.org> References: <20120105200442.GA17669@annexia.org> Date: Thu, 5 Jan 2012 20:27:25 +0000 Message-ID: From: ivan chollet To: "Richard W.M. Jones" Cc: Lukasz Stafiniak , Diego Olivier Fernandez Pons , caml-list Content-Type: multipart/alternative; boundary=90e6ba3fd25da1231d04b5cdc2dc Subject: Re: [Caml-list] Examples where let rec is undesirable --90e6ba3fd25da1231d04b5cdc2dc Content-Type: text/plain; charset=ISO-8859-1 Allowing variable shadowing is aesthetically more satisfying and more expressive, but opens the door to bugs that can be harder to track by static analysis. I would be interested to hear the pro-arguments for variable shadowing, besides the slight gain in expressiveness. On Thu, Jan 5, 2012 at 8:04 PM, Richard W.M. Jones wrote: > On Tue, Jan 03, 2012 at 01:05:39AM +0100, Lukasz Stafiniak wrote: > > On Mon, Jan 2, 2012 at 11:37 PM, Diego Olivier Fernandez Pons > > wrote: > > > List, > > > > > > I was wondering if there was any reason not to make "let rec" the > default / > > > sole option, meaning cases where you clearly don't want a "let rec" > instead > > > of "let" (only in functions, not cyclic data). > > > > > > Diego Olivier > > > > The default "no-rec" allows for name recycling -- using the same name > > for an incrementally transformed value, i.e. to bind the intermediate > > results. Name recycling minimizes the cognitive burden: there are less > > names to remember in a scope, and differences in names are justified > > by differences in purpose of the values. Are there reasons to consider > > name recycling a bad style? > > I had an argument about this with a noted open source developer > recently. He was saying that C's approach -- not permitting variable > names to be reused within a single function -- was somehow > advantageous. From my point of view, having used both languages > extensively, OCaml's way is *far* better. > > So yes, 'let' and 'let rec', long may they be different. > > Rich. > > -- > Richard Jones > Red Hat > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa-roc.inria.fr/wws/info/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > > --90e6ba3fd25da1231d04b5cdc2dc Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Allowing variable shadowing is aesthetically more satisfying and more expre= ssive, but opens the door to bugs that can be harder to track by static ana= lysis.
I would be interested to hear the pro-arguments for variable shad= owing, besides the slight gain in expressiveness.


On Thu, Jan 5, 2012 at 8:04 PM, Richard = W.M. Jones <rich@a= nnexia.org> wrote:
On Tue, Jan 03, 2012 at 01:05:39AM +0100, Lukasz Stafiniak wrote:
> On Mon, Jan 2, 2012 at 11:37 PM, Diego Olivier Fernandez Pons
> <dofp.ocaml@gmail.com&g= t; wrote:
> > =A0 =A0 List,
> >
> > I was wondering if there was any reason not to make "let rec= " the default /
> > sole option, meaning cases where you clearly don't want a &qu= ot;let rec" instead
> > of "let" (only in functions, not cyclic data).
> >
> > =A0 =A0 =A0 =A0 =A0Diego Olivier
>
> The default "no-rec" allows for name recycling -- using the = same name
> for an incrementally transformed value, i.e. to bind the intermediate<= br> > results. Name recycling minimizes the cognitive burden: there are less=
> names to remember in a scope, and differences in names are justified > by differences in purpose of the values. Are there reasons to consider=
> name recycling a bad style?

I had an argument about this with a noted open source developer
recently. =A0He was saying that C's approach -- not permitting variable=
names to be reused within a single function -- was somehow
advantageous. =A0From my point of view, having used both languages
extensively, OCaml's way is *far* better.

So yes, 'let' and 'let rec', long may they be different.

Rich.

--
Richard Jones
Red Hat

--
Caml-list mailing list. =A0Subscription management and archives:
https://sympa-roc.inria.fr/wws/info/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


--90e6ba3fd25da1231d04b5cdc2dc--