From: brogoff@speakeasy.net
To: Olivier Andrieu <andrieu@ijm.jussieu.fr>
Cc: "Eric C. Cooper" <ecc@cmu.edu>,
"caml-list@inria.fr" <caml-list@inria.fr>
Subject: Re: [Caml-list] suggestion for record pattern matching and construction
Date: Sun, 14 Sep 2003 12:32:52 -0700 (PDT) [thread overview]
Message-ID: <Pine.LNX.4.44.0309141222090.5657-100000@grace.speakeasy.net> (raw)
In-Reply-To: <16223.45432.216362.752939@karryall.dnsalias.org>
On Thu, 11 Sep 2003, Olivier Andrieu wrote:
> Eric C. Cooper [Wednesday 10 September 2003] :
> >
> > I find that I am often writing code like
> > { field1 = field1; field2 = field2; field3 = field3 }
> > when matching and constructing records. I guess it's because thinking
> > up good names for the record fields is nontrivial and having similar
> > but different names for the bindings just bothers me.
> >
> > How about allowing syntax like that used for labels:
> > { ~field1; ~field2; ~field3 }
> > would expand into the above, in both pattern matching and construction
> > contexts.
>
> I have a camlp4 extension that does exactly this (well, without
> the ~). Also, you can put the module path before the { instead of
> having to repeat it for each field. So :
>
> Mod1.Mod2.{ field1; field2 }
>
> is expanded into
>
> { Mod1.Mod2.field1 = field1 ; Mod1.Mod2.field2 = field2 }
I like it, though I can even see an argument for the ~ syntax Eric suggests as
it dovetails nicely with labels. I especially like your sugar which reduces
the number of module qualifications.
Is there any chance we could see a feature like this in the core language
syntax? Especially since 3.07, I am more inclined to use "private" record
types a lot more, and since I'd also like to minimize my use of open, this
lighter syntax makes it even more appealing.
-- Brian
-------------------
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
next prev parent reply other threads:[~2003-09-14 19:32 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-09-10 18:52 Eric C. Cooper
2003-09-10 23:19 ` Olivier Andrieu
2003-09-14 19:32 ` brogoff [this message]
2003-09-11 13:49 ` [Caml-list] FreeBSD + lablglut + thread: bug or not bug Christophe Raffalli
2003-09-11 14:25 ` Christophe Raffalli
2003-09-11 14:30 ` Gerd Stolpmann
2003-09-11 15:11 ` Christophe Raffalli
2003-09-11 15:23 ` Gerd Stolpmann
2003-09-11 17:33 ` Issac Trotts
2003-09-11 20:01 ` Christophe Raffalli
2003-09-11 20:09 ` Christophe Raffalli
2003-09-11 20:38 ` Issac Trotts
2003-09-12 5:57 ` Christophe Raffalli
2003-09-12 6:34 ` Gerd Stolpmann
2003-09-22 12:16 ` Christophe Raffalli
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.LNX.4.44.0309141222090.5657-100000@grace.speakeasy.net \
--to=brogoff@speakeasy.net \
--cc=andrieu@ijm.jussieu.fr \
--cc=caml-list@inria.fr \
--cc=ecc@cmu.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