Browse thread
[Caml-list] semi-colons and begin
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2001-04-04 (22:09) |
From: | Chris Hecker <checker@d...> |
Subject: | [Caml-list] semi-colons and begin |
I must admit I'm still slightly confused about the semicolon thing, even after writing a fair amount of caml code. The current sticking point is that # if false then print_int 2; print_int 3;; 3- : unit = () # if false then print_int 2; print_int 3 else ();; Characters 39-43: Syntax error # # if false then begin print_int 2; print_int 3 end;; - : unit = () # if false then begin print_int 2; print_int 3 end else ();; - : unit = () The "BNF" grammar implies the first and second tests should compile and print nothing, since expr = expr ; expr, although Xavier et al. have said the BNF in the docs isn't really accurate. I also thought begin...end was needed in a pattern-match, but apparently expr ; expr works there? Is there a chart or something that says exactly where they're allowed? I'm afraid of introducing a subtle bug in my program. In C I always use brackets with my if statements to avoid the similar problem, so I suppose I could use begin..end everywhere, but yuck! Chris ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr