Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Andreas Rossberg <rossberg@ps.uni-sb.de>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Record pattern matching
Date: Fri, 11 May 2001 10:00:04 +0200	[thread overview]
Message-ID: <3AFB9C04.AD291AC6@ps.uni-sb.de> (raw)
In-Reply-To: <0C682B70CE37BC4EADED9D375809768A02DB1FEF@red-msg-04.redmond.corp.microsoft.com>

> >       You'd rather be forced to code something like:
> >
> >       function { a=a; b=_ } -> a;;
> >
> > where all the fields have to be named, but some of them can
> > be specified as ignored?

No, but as Don suggested having alternative syntax would be preferable.
SML for example distinguishes the patterns

	{a = p}

and

	{a = p, ...}

> I guess the point is that I don't use record pattern matching much, and
> where I do I don't want partial matches.  Or at least I have a cases
> where enforcing full matching would catch more bugs.

This has been my experience as well when modifying record types.

> > There is a sense in which
> >
> >       record.a
> >
> > is just a shorthand for
> >
> >       match record with { a=value } -> value
> >
> > which means that you might argue that the notation
> >
> >       record.a
> >
> > should be completed by naming every field too :-)

In SML the record selection function #a in fact is sugar for

	fn {a=x, ...} => x

Best regards,

	- Andreas

-- 
Andreas Rossberg, rossberg@ps.uni-sb.de

"Computer games don't affect kids.
 If Pac Man affected us as kids, we would all be running around in
 darkened rooms, munching pills, and listening to repetitive music."
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


  reply	other threads:[~2001-05-11  8:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-05-10 18:43 Don Syme
2001-05-11  8:00 ` Andreas Rossberg [this message]
2001-05-11  9:04   ` John Max Skaller
2001-05-12 17:11   ` Brian Rogoff
  -- strict thread matches above, loose matches on Subject: below --
2001-05-07 15:33 Don Syme
2001-05-07 18:37 ` John Max Skaller

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=3AFB9C04.AD291AC6@ps.uni-sb.de \
    --to=rossberg@ps.uni-sb.de \
    --cc=caml-list@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