From: Sven LUTHER <luther@dpt-info.u-strasbg.fr>
To: Alex Baretta <alex@baretta.com>
Cc: "caml-list@inria.fr" <caml-list@inria.fr>
Subject: Re: [Caml-list] Records
Date: Thu, 22 Mar 2001 14:10:18 +0100 [thread overview]
Message-ID: <20010322141018.A27738@lambda.u-strasbg.fr> (raw)
In-Reply-To: <3AB9F13C.1B77C08@baretta.com>; from alex@baretta.com on Thu, Mar 22, 2001 at 01:34:04PM +0100
On Thu, Mar 22, 2001 at 01:34:04PM +0100, Alex Baretta wrote:
> Basically I'm trying to define two record type as sharing some
> field names. I have tried twice, apparently in the same way, and
> obtained two different error messages, which seem to contradict
> one another. Could anyone explain to me what is happening here?
>
>
> Objective Caml version 3.00
>
> # type rec1 = { field1 : int }
> type rec2 = { field1 : int ; field2 : int };; <--- Here I define
> my two record types
> type rec1 = { field1 : int; }
> type rec2 = { field1 : int; field2 : int; }
> # { field1 = 1 };; <--- This is supposed to be a correct rec1
no, it is a rec2 record, since field1 was lastly defined for rec2.
One workaround would be :
module Rec1 = struct
type t = {field1 : int}
end
module Rec2 = struct
type t = { field1 : int; field2 : int; }
end
Then you can do :
{Rec1.field1 = 1} : Rec1.t
or
{Rec2.field1 = 1; Rec2.field2 = 2} : Rec2.t
If you are interrestedin more such things, i remember a discution about such
things some time ago on this list, please look at the mailing list archive for
more details.
Friendly,
Sven Luther
-------------------
To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr
prev parent reply other threads:[~2001-03-22 13:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-03-22 12:34 Alex Baretta
2001-03-22 13:10 ` Sven LUTHER [this message]
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=20010322141018.A27738@lambda.u-strasbg.fr \
--to=luther@dpt-info.u-strasbg.fr \
--cc=alex@baretta.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