caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Alex Baretta <alex@baretta.com>
To: "caml-list@inria.fr" <caml-list@inria.fr>
Subject: [Caml-list] Records
Date: Thu, 22 Mar 2001 13:34:04 +0100	[thread overview]
Message-ID: <3AB9F13C.1B77C08@baretta.com> (raw)

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
variable.
Some record field labels are undefined <--- Why? rec1 defines
field1
# { field2 = 2 };; 
Some record field labels are undefined <--- Here I agree with the
interpreter
# { field1 = 1 ; field2 = 2 };;
- : rec2 = {field1=1; field2=2}      <--- Ok, so apparently he
likes records with 2 fields...

Now I try again, but this time I begin by defining a record with
two fields, and then I define a second one which shares one of
them.

# type var_def_rec = {name: string; value: int}
type var_decl_rec= {name: string}  ;;
type var_def_rec = { name : string; value : int; } 
type var_decl_rec = { name : string; } <--- Ok, so he accepted
them.
# { name = "alex" ; value = 1 };;
The record field label value belongs to the type var_def_rec
but is here mixed with labels of type var_decl_rec <--- Hein!
What?
# { name = "pippo" };;
- : var_decl_rec = {name="pippo"} <--- Now he seems to like
records with one field only!


WHY?

I cannot make any sense out of this. Please, help me.

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


             reply	other threads:[~2001-03-22 12:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-22 12:34 Alex Baretta [this message]
2001-03-22 13:10 ` Sven LUTHER

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=3AB9F13C.1B77C08@baretta.com \
    --to=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;
as well as URLs for NNTP newsgroup(s).