From: Jon Harrop <jon@jdh30.plus.com>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Strange syntax error
Date: Sun, 23 Jan 2005 21:49:54 +0000 [thread overview]
Message-ID: <200501232149.54437.jon@jdh30.plus.com> (raw)
In-Reply-To: <20050123211112.GA14067@furbychan.cocan.org>
On Sunday 23 January 2005 21:11, Richard Jones wrote:
> ...
> Is this a parsing bug?
I assume a "when" clause is only allowed at the end of the list of alternative
patterns. For example:
let f = function
{ keyword = keyword } -> keyword
| { keyword = keyword; cost = None } when keyword.[0] = '-' -> keyword
| _ -> failwith "whatever"
is allowed (but not what you wanted).
I guess that allowing "when" clauses on each alternative pattern would obviate
the advantages of using a decision tree to represent pattern matching and,
therefore, would make pattern matches significantly more inefficient. Hence
they don't do it.
In this case, I'd go for:
let f = function
{ keyword = keyword } when keyword.[0] = '-' -> keyword
| { cost = None } as t -> t.keyword
| _ -> failwith "whatever"
Say, this wouldn't be related to that arg-passing problem would it? ;-)
Cheers,
Jon.
next prev parent reply other threads:[~2005-01-23 21:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-23 21:11 Richard Jones
2005-01-23 21:44 ` [Caml-list] " Nicolas Cannasse
2005-01-23 21:49 ` Jon Harrop [this message]
2005-01-23 22:23 ` Kurt Welgehausen
2005-01-23 23:12 ` Richard Jones
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=200501232149.54437.jon@jdh30.plus.com \
--to=jon@jdh30.plus.com \
--cc=caml-list@yquem.inria.fr \
/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;
as well as URLs for NNTP newsgroup(s).