let test1 b =
if b then
print_string "1"
else
print_string "2"; print_string "3"
> Here print_string "3" is not a part of the if expression, so this function always prints “3”.Well, yeah. Here's the equivalent Java code:
void test1(bool b) {
if (b) print_string("1");
else print_string("2");
print_string("3");
}
You've chosen to use a single-statement "else" form _without_ "bracketing" it with `begin` and `end`: let test1 b =
if b then
print_string "1"
else begin
print_string "2";
print_string "3"
end
...which is equivalent to this Java code, where you _also_ would have to "bracket" the else-block: void test1(bool b) {
if (b) print_string("1");
else {
print_string("2");
print_string("3");
}
}
You could argue that Java (and C, and C++, and Javascript, and...) has the same "ambiguous parsing problem", then -- except that it doesn't, and the author is just thrown off by `begin`/`end` as block delimiters instead of curly braces, which might be a sign that they've also never seen Ruby before, or Elixir, or Pascal, or....