From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id JAA09323 for caml-redistribution; Tue, 22 Jul 1997 09:19:57 +0200 (MET DST) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id QAA28141 for ; Mon, 21 Jul 1997 16:48:58 +0200 (MET DST) Received: from yeti2.didac-mip.fr (root@yeti2.didac-mip.fr [130.120.37.106]) by nez-perce.inria.fr (8.8.5/8.7.3) with ESMTP id QAA23347 for ; Mon, 21 Jul 1997 16:48:57 +0200 (MET DST) Received: from yeti2.didac-mip.fr (localhost [127.0.0.1]) by yeti2.didac-mip.fr (8.8.5/8.8.5) with ESMTP id QAA02229 for ; Mon, 21 Jul 1997 16:49:03 +0200 Message-Id: <199707211449.QAA02229@yeti2.didac-mip.fr> X-Mailer: exmh version 1.6.9 05/05/96 To: caml-list@inria.fr Subject: problemes de types Reply-to: laffitte@didac-mip.fr X-uri: http://www.didac-mip.fr/ Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Mon, 21 Jul 1997 16:49:03 +0200 From: Jean-Claude Laffitte Sender: weis 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.