caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Brian Rogoff <bpr@best.com>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Record pattern matching
Date: Sat, 12 May 2001 10:11:57 -0700 (PDT)	[thread overview]
Message-ID: <Pine.BSF.4.21.0105120950510.19089-100000@shell5.ba.best.com> (raw)
In-Reply-To: <3AFB9C04.AD291AC6@ps.uni-sb.de>

On Fri, 11 May 2001, Andreas Rossberg wrote:
> > >       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, ...}

This seems like a good solution to this problem.

> > 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.

OK, just to provide another data point, I use the partial match feature
quite a bit. The "..." notation is light enough that the feature is still 
convenient, which would not be the case if each named field would have to
be explicitly named. I've also been reading a lot of SML code that I
haven't written lately and I find that notation quite readable and
concise.

As an aside, the situation with records is still not very satisfying. In
some cases I use objects when I really just want flexible records, where I 
can define functions over all records types with given fields. It seems
that would be more "symmetric" too, with respect to polymorphic variants.
I gather something like that has been tried already and found wanting?

-- Brian


-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


  parent reply	other threads:[~2001-05-12 17:12 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
2001-05-11  9:04   ` John Max Skaller
2001-05-12 17:11   ` Brian Rogoff [this message]
  -- 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=Pine.BSF.4.21.0105120950510.19089-100000@shell5.ba.best.com \
    --to=bpr@best.com \
    --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;
as well as URLs for NNTP newsgroup(s).