* Revised syntax scope (3.10 vs. 3.11)
@ 2009-03-27 4:42 Andre Nathan
2009-03-27 9:45 ` [Caml-list] " Nicolas Pouillard
0 siblings, 1 reply; 3+ messages in thread
From: Andre Nathan @ 2009-03-27 4:42 UTC (permalink / raw)
To: caml-list
Hello
I've found the following difference of behavior between OCaml 3.10 and
3.11. The code below
<:expr<
do {
let a = "foo" in
print_endline a;
print_endline a
}
>>
when run through camlp4o becomes, in 3.10,
let a = "foo" in (print_endline a; print_endline a)
while in 3.11 it becomes
((let a = "foo" in print_endline a); print_endline a)
which causes `a' to become out of scope in the second print_endline.
Is the behavior of 3.11 the correct one? I had to move the binding
of `a' out of the do block so that this works in both versions.
Thanks,
Andre
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] Revised syntax scope (3.10 vs. 3.11)
2009-03-27 4:42 Revised syntax scope (3.10 vs. 3.11) Andre Nathan
@ 2009-03-27 9:45 ` Nicolas Pouillard
2009-03-27 14:43 ` Andre Nathan
0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Pouillard @ 2009-03-27 9:45 UTC (permalink / raw)
To: Andre Nathan; +Cc: caml-list
Excerpts from Andre Nathan's message of Fri Mar 27 05:42:34 +0100 2009:
> Hello
>
> I've found the following difference of behavior between OCaml 3.10 and
> 3.11. The code below
>
> <:expr<
> do {
> let a = "foo" in
> print_endline a;
> print_endline a
> }
> >>
>
> when run through camlp4o becomes, in 3.10,
>
> let a = "foo" in (print_endline a; print_endline a)
>
> while in 3.11 it becomes
>
> ((let a = "foo" in print_endline a); print_endline a)
>
> which causes `a' to become out of scope in the second print_endline.
> Is the behavior of 3.11 the correct one? I had to move the binding
> of `a' out of the do block so that this works in both versions.
That was indeed the intended behavior, to get a larger scope for 'a'
use this syntax:
<:expr<
do {
let a = "foo"; (* <--- semicolon here *)
print_endline a;
print_endline a
}
>>
--
Nicolas Pouillard
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] Revised syntax scope (3.10 vs. 3.11)
2009-03-27 9:45 ` [Caml-list] " Nicolas Pouillard
@ 2009-03-27 14:43 ` Andre Nathan
0 siblings, 0 replies; 3+ messages in thread
From: Andre Nathan @ 2009-03-27 14:43 UTC (permalink / raw)
To: Nicolas Pouillard; +Cc: caml-list
On Fri, 2009-03-27 at 10:45 +0100, Nicolas Pouillard wrote:
> That was indeed the intended behavior, to get a larger scope for 'a'
> use this syntax:
>
> <:expr<
> do {
> let a = "foo"; (* <--- semicolon here *)
> print_endline a;
> print_endline a
> }
> >>
Thank you!
Andre
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-03-27 14:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-27 4:42 Revised syntax scope (3.10 vs. 3.11) Andre Nathan
2009-03-27 9:45 ` [Caml-list] " Nicolas Pouillard
2009-03-27 14:43 ` Andre Nathan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox