Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Markus Mottl <mottl@miss.wu-wien.ac.at>
To: "David Mentré" <David.Mentre@irisa.fr>
Cc: caml-list@inria.fr
Subject: Re: [newbie] Define and use records in sum types
Date: Mon, 17 Jul 2000 12:01:51 +0200	[thread overview]
Message-ID: <20000717120151.A32148@miss.wu-wien.ac.at> (raw)
In-Reply-To: <wd8d7kkewbr.fsf@parate.irisa.fr>; from David.Mentre@irisa.fr on Tue, Jul 11, 2000 at 13:32:40 +0200

On Tue, 11 Jul 2000, David Mentré wrote:
> I would like to define a sum type with records as constructor
> parameters, records with the same field names. 

It is unfortunately not possible to use records with the same names at the
same time without putting them into separate modules.

> It *seems* to work but, in fact, the a_rec definition is masked by b_rec
> definition:

Exactly: names of record fields get overridden by subsequent definitions.
There is no way to get the "old" meaning back without the use of modules.

> The rationale behind this question: I find records more clear that
> tuples in source code.

Using records makes sources more readable and also easier to maintain. For
example, the "with" statement as in

  { some_record with some_field = some_value; ... }
  
allows adding fields to records without breaking code.

Best regards,
Markus Mottl

-- 
Markus Mottl, mottl@miss.wu-wien.ac.at, http://miss.wu-wien.ac.at/~mottl



  reply	other threads:[~2000-07-19 15:41 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-07-11 11:32 David Mentré
2000-07-17 10:01 ` Markus Mottl [this message]
     [not found]   ` <14709.63462.792269.194367@ish.artisan.com>
2000-07-19 20:10     ` Markus Mottl
2000-07-21 12:23       ` Frank Atanassow
2000-07-21 20:00         ` Markus Mottl
2000-07-22 13:34           ` Frank Atanassow
2000-07-22 18:31             ` Markus Mottl
2000-07-23 13:55               ` Frank Atanassow
2000-07-23 15:20                 ` Markus Mottl
2000-07-24  9:28                   ` Frank Atanassow
2000-07-25  5:26                     ` Alan Schmitt
2000-07-19 19:21 ` Jean-Christophe Filliatre
2000-07-20  7:08   ` David Mentré

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=20000717120151.A32148@miss.wu-wien.ac.at \
    --to=mottl@miss.wu-wien.ac.at \
    --cc=David.Mentre@irisa.fr \
    --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