caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] semi-colons and begin
@ 2001-04-04 21:33 Chris Hecker
  2001-04-04 22:40 ` Gerd Stolpmann
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Chris Hecker @ 2001-04-04 21:33 UTC (permalink / raw)
  To: caml-list


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


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2001-04-08 20:12 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-04 21:33 [Caml-list] semi-colons and begin Chris Hecker
2001-04-04 22:40 ` Gerd Stolpmann
2001-04-04 23:32   ` Chris Hecker
2001-04-05  1:03     ` mahamud
2001-04-05  3:48       ` Brian Rogoff
2001-04-05  6:05       ` David Brown
2001-04-06  9:33     ` Gerd Stolpmann
2001-04-05  3:35 ` Michael Hicks
2001-04-05  3:53 ` Daniel de Rauglaudre
2001-04-05  6:23   ` Mattias Waldau
2001-04-05 17:34     ` Pierre Weis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).