caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Jim Miller" <gordon.j.miller@gmail.com>
To: "Jonathan Roewen" <jonathan.roewen@gmail.com>, caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Pattern matching question
Date: Wed, 19 Jul 2006 21:03:11 -0400	[thread overview]
Message-ID: <beed19130607191803q315dd241k87be4218a805e3d@mail.gmail.com> (raw)
In-Reply-To: <ad8cfe7e0607191737l551e1d8aif8d5859fb6c398fd@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1403 bytes --]

On 7/19/06, Jonathan Roewen <jonathan.roewen@gmail.com> wrote:
>
> > let receive idList msg =
> >   match message with
> >      None -> None
> >
> > |    Register( REQUEST_KEY, id ) -> begin
> >          match idList with
> >              [] -> Register(SUCCESS, id)
> >          |   l when (List.mem id l) -> Register(Success,
> (next_available_id
> > l))
> >          |  _ -> Register(Success, id)
> > ;;
>
> For the inner match, why you even both with it is beyond me. All you
> are doing is wrapping List.mem in an unnecessary test.
>
> It should be:
> | Register(REQUEST_KEY,id) ->
>    if List.mem id idList then
>       Register(Success, next_available_id l)
>    else
>       Register(Success, id)
>
> Perhaps the fact that your example makes no sense (it's not a complete
> definition, nor is Success defined anywhere, nor does Register even
> accept the constructor Success) doesn't help here.



The main purpose is not to actually construct a program but to construct a
specification of a communications protocol in a syntax that I can give to a
non-coder and have them read but also have some validation that I'm checking
all possible cases.

You are correct in your statement that the match isn't necessary but that's
assuming that I care about the program.  The match is much more explicit to
a non-coder (at least that's the feedback I've gotten) of the case that
we''re trying to test.

[-- Attachment #2: Type: text/html, Size: 2174 bytes --]

  parent reply	other threads:[~2006-07-20  1:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-19 18:48 Jim Miller
2006-07-19 18:55 ` [Caml-list] " Seth J. Fogarty
     [not found] ` <ad8cfe7e0607191737l551e1d8aif8d5859fb6c398fd@mail.gmail.com>
2006-07-20  1:03   ` Jim Miller [this message]
2006-07-20  8:38 ` Luc Maranget

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=beed19130607191803q315dd241k87be4218a805e3d@mail.gmail.com \
    --to=gordon.j.miller@gmail.com \
    --cc=caml-list@yquem.inria.fr \
    --cc=jonathan.roewen@gmail.com \
    /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).