Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: "Nicolas Pouillard" <nicolas.pouillard@inria.fr>
To: "Serge Aleynikov" <serge@hq.idt.net>
Cc: "Dmitri Boulytchev" <db@tepkom.ru>,
	bhurt@janestcapital.com, caml-list@inria.fr
Subject: Re: [Caml-list] camlp4 scope issue
Date: Wed, 25 Oct 2006 18:17:29 +0200	[thread overview]
Message-ID: <cd67f63a0610250917i538b9553v5e9cf7e0f5308b5b@mail.gmail.com> (raw)
In-Reply-To: <453F8AF8.4090306@hq.idt.net>

On 10/25/06, Serge Aleynikov <serge@hq.idt.net> wrote:
> Perhaps I am misunderstanding the meaning of ";" in the revised syntax,
> however, the 6.2 chapter
> (http://caml.inria.fr/pub/docs/manual-camlp4/manual007.html) says that:
>
> do { e1; e2; e3; e4 }
>
> is an iterative sequence of expressions, whereas "let ... in" is
> reserved for local constructs.
>
> If so, wouldn't the scope of y in
>
> let y = 1 in do { a; b; c };
>
> be different from:
>
> let y = 1 in a; b; c;
>
> Or else how to we indicate in the *revised syntax* the boundary of the
> "let ... in" scope?

It's not a bug it's a feature :)

But a not documented one.

Inside a << do { ... } >> you can use << let var = expr1; expr2 >>
like << let var = expr1 in expr2 >>.

The main goal is to facilitate imperative coding inside a << do {} >>:

do {
  let x = 42;
  do_that_on x;
  let y = x + 2;
  play_with y;
}

That's nice but undocumented :(

Without such a syntax the regular one will make you nest do { ... } notations.

do {
  foo 1;
  let x = 43 in do {
     bar x;
  };
  (* x should be out of the scope *)
}

Alas << let ... in >> and << let ... ; >> have the same semantics
inside a << do { ... } >> what I regret because << let ... in >> is
not local anymore.

In plain OCaml it's different since << ; >> is a binary operator so
you must see << let a = () in a; a >> like << let a = () in (a; a) >>.

Hope this helps...

Best regards,

-- 
Nicolas Pouillard


  reply	other threads:[~2006-10-25 16:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-25 15:36 Serge Aleynikov
2006-10-25 19:42 ` [Caml-list] " Dmitri Boulytchev
2006-10-25 16:04   ` Serge Aleynikov
2006-10-25 16:17     ` Nicolas Pouillard [this message]
2006-10-25 16:35       ` Serge Aleynikov
2006-10-25 20:19     ` Dmitri Boulytchev
2006-10-25 16:21       ` Mike Lin

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=cd67f63a0610250917i538b9553v5e9cf7e0f5308b5b@mail.gmail.com \
    --to=nicolas.pouillard@inria.fr \
    --cc=bhurt@janestcapital.com \
    --cc=caml-list@inria.fr \
    --cc=db@tepkom.ru \
    --cc=serge@hq.idt.net \
    /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