From: "Mike Lin" <mikelin@mit.edu>
To: caml-list@inria.fr
Subject: Re: [Caml-list] camlp4 scope issue
Date: Wed, 25 Oct 2006 12:21:06 -0400 [thread overview]
Message-ID: <2a1a1a0c0610250921p5a4d6b22ic146a96e1fcac51f@mail.gmail.com> (raw)
In-Reply-To: <453FC6D5.2040404@tepkom.ru>
[-- Attachment #1: Type: text/plain, Size: 2426 bytes --]
I would like to take this opportunity to plug ocaml+twt. Relieve your
suffering...
http://people.csail.mit.edu/mikelin/ocaml+twt/
On 10/25/06, Dmitri Boulytchev <db@tepkom.ru> wrote:
>
> The revised syntax description you are referring to is quite
> informal so I'd rather trust the compiler :)
> You may restict the scope of a binding in a way its usual done in
> other languages: by
>
> do {let y = 1 in a}; b; c;
>
> in revised or by
>
> (let y = 1 in a); b; c;
>
> in standard syntax.
>
> BR,
> DB.
>
> > 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?
> >
> > Serge
> >
> > Dmitri Boulytchev wrote:
> >
> >> That's ok - semicolon does not restict the scope since it plays
> role
> >> of a binary operation, not a statement delimiter. So in your example
> >>
> >> (); Printf.printf "y should be out of scope, but it's not: y =
> >> %d\n" y
> >> is a while scope for let-binding.
> >>
> >> Best regards,
> >> Dmitri Boulytchev,
> >> St.Petersburg State University.
> >>
> >>
> >>> Hi,
> >>>
> >>> In the test program below in my understanding the 'y' variable
> >>> should be
> >>> out of scope in the printf statement, but apparently it's not. The
> >>> compiler version is 3.09.3.
> >>>
> >>> $ cat tst.ml
> >>> value f z = z + 1;
> >>>
> >>> let x = 1 in do {
> >>> let y = f x in ();
> >>> Printf.printf "y should be out of scope, but it's not: y = %d\n" y
> >>> };
> >>>
> >>> $ ocamlc -o tst -pp camlp4r tst.ml
> >>> $ ./tst
> >>> y should be out of scope, but it's not: y = 2
> >>>
> >>>
> >>> Any idea why?
> >>>
> >>
> >>
> >
> >
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
[-- Attachment #2: Type: text/html, Size: 3953 bytes --]
prev parent reply other threads:[~2006-10-25 16:21 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
2006-10-25 16:35 ` Serge Aleynikov
2006-10-25 20:19 ` Dmitri Boulytchev
2006-10-25 16:21 ` Mike Lin [this message]
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=2a1a1a0c0610250921p5a4d6b22ic146a96e1fcac51f@mail.gmail.com \
--to=mikelin@mit.edu \
--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