From: Xavier Leroy <xavier.leroy@inria.fr>
To: John Carr <jfc@MIT.EDU>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] syntax question -- end of pattern-matching
Date: Fri, 19 Jul 2002 14:00:26 +0200 [thread overview]
Message-ID: <20020719140026.A32590@pauillac.inria.fr> (raw)
In-Reply-To: <200207181927.PAA18741@psi-phi.mit.edu>; from jfc@MIT.EDU on Thu, Jul 18, 2002 at 03:27:16PM -0400
> If I write a match directly within another match, or a try ... with
> expression in a sequence of expressions, it is often necessary to
> use two semicolons separated by whitespace after the pattern matching.
>
> For example,
>
> let f x = try x + 1 with Invalid_argument _ -> 42 ; "hello"
>
> is parsed as
>
> let f x = try x + 1 with Invalid_argument _ -> (42 ; "hello")
>
> (and causes a type error), but if I add a second semicolon
>
> let f x = try x + 1 with Invalid_argument _ -> 42 ; ; "hello"
>
> is parsed as
>
> let f x = (try x + 1 with Invalid_argument _ -> 42;) ; "hello"
Please don't use the "; ;" form: it has never been intended to work,
it's just an unexpected consequence of some other decisions made in
the Yacc grammar.
The proper way to write what you want is
let f x = (try x + 1 with Invalid_argument _ -> 42) ; "hello"
or
let f x = begin try x + 1 with Invalid_argument _ -> 42 end; "hello"
- Xavier Leroy
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
prev parent reply other threads:[~2002-07-19 12:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-07-18 19:27 John Carr
2002-07-19 8:33 ` Daniel de Rauglaudre
2002-07-19 12:00 ` Xavier Leroy [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=20020719140026.A32590@pauillac.inria.fr \
--to=xavier.leroy@inria.fr \
--cc=caml-list@inria.fr \
--cc=jfc@MIT.EDU \
/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