caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Damien Doligez <damien.doligez@inria.fr>
To: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Examples where let rec is undesirable
Date: Fri, 6 Jan 2012 16:22:42 +0100	[thread overview]
Message-ID: <8F3B10C5-01DC-49D4-A233-40413D73C55A@inria.fr> (raw)
In-Reply-To: <CAPFanBGLcExE0pJRVv6d3sUpuxbft=2i4Z5zbJ_SHJBFBOREuQ@mail.gmail.com>

On 2012-01-05, at 21:46, Gabriel Scherer wrote:

> My argument is the following: when you make a *local* edition to a
> piece of code, shadowing allow you to pick variable name without
> having to know about what's already bound in context.

I agree with Gabriel.  Consider the following expression:

   (let x = 21 in x + x)

Assuming I haven't been so crazy as to redefine (+), is this
a valid expression whose value is 42?

First possible answer: yes
Second possible answer: it depends on the context.

I'd rather go with the first choice, and that means allowing
shadowing.  Consider a camlp4 extension that produces such
expressions.  Does it have to look at the context (including
the "open" statements, functor applications, first-class
modules, etc.) before it can insert this expression into your
code?

-- Damien


  parent reply	other threads:[~2012-01-06 15:22 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-02 22:37 Diego Olivier Fernandez Pons
2012-01-02 22:49 ` Alexandre Pilkiewicz
2012-01-03  0:05 ` Lukasz Stafiniak
2012-01-03  5:47   ` Martin Jambon
2012-01-03  8:07     ` Gabriel Scherer
2012-01-05 20:04   ` Richard W.M. Jones
2012-01-05 20:27     ` ivan chollet
2012-01-05 20:46       ` Gabriel Scherer
2012-01-05 21:39         ` Richard W.M. Jones
2012-01-06  2:39           ` Cedric Cellier
2012-01-06 15:22         ` Damien Doligez [this message]
2012-01-05 21:36       ` Richard W.M. Jones
2012-01-05 23:16         ` ivan chollet
2012-01-06  8:34           ` David Allsopp
2012-01-06 10:34           ` Daniel Bünzli
2012-01-03 13:05 ` Yaron Minsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8F3B10C5-01DC-49D4-A233-40413D73C55A@inria.fr \
    --to=damien.doligez@inria.fr \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).