From: Jean-Claude Laffitte <laffitte@yeti2.didac-mip.fr>
To: caml-list@inria.fr
Subject: problemes de types
Date: Mon, 21 Jul 1997 16:49:03 +0200 [thread overview]
Message-ID: <199707211449.QAA02229@yeti2.didac-mip.fr> (raw)
j'ai un petit probleme avec les definitions de types. Lorsque je definis deux
types enregistrements ayant un champ portant le meme nom, le compilateur
semble avoir du mal a reconnaitre les types de mes variables.
voici un exemple :
Ex1 :
(*------------------------------------------------------------------*)
type var = {
mutable id : int;
mutable date : int
}
type alrm = {
mutable acq : bool;
mutable id : int;
mutable valeur : string
}
let test (a : var) (b : alrm) =
if ( a.date = 100) then print_string b.valeur;
if ( a.id = 10 ) then print_int b.id
(*------------------------------------------------------------------*)
File "t1.ml", line 15, characters 7-8:
This expression has type var but is here used with type alrm
Ne peut on pas definir deux types ayant un champ de meme nom ou est ce qu'un
detail m'aurait echappe ??
Le meme type de conflit existe avec les types enumeres.
Ex2 :
(*------------------------------------------------------------------*)
type var = Ident | Date
type alrm = Acq | Ident | Valeur
let test (a : var) =
match a with
Ident -> ();
| Date -> ()
(*------------------------------------------------------------------*)
File "t2.ml", line 7, characters 4-9:
This pattern matches values of type alrm
but is here used to match values of type var
**********************************************************************
English summary
**********************************************************************
I've a little problem with record types. When I define two types with a common
field name, the compiler seems to have problems to recognize the type of
variables.
See Ex1.
The same problems appears with variant types.
See Ex2.
next reply other threads:[~1997-07-22 7:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-07-21 14:49 Jean-Claude Laffitte [this message]
1997-07-22 7:29 ` Pierre Weis
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=199707211449.QAA02229@yeti2.didac-mip.fr \
--to=laffitte@yeti2.didac-mip.fr \
--cc=caml-list@inria.fr \
--cc=laffitte@didac-mip.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