Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Frederic Tronel <Frederic.Tronel@inrialpes.fr>
To: caml-list@inria.fr
Subject: [Caml-list] Problem with parametric classes
Date: Mon, 22 Apr 2002 10:43:49 +0200	[thread overview]
Message-ID: <3CC3CD45.E6D6E166@inrialpes.fr> (raw)

Hello,

I'm using Ocaml 3.04 (plus a patch applied to circumvent a 
problem with parametric classes bug id 841).

I'm trying to compile the following piece of code (more
precisely, this is a significant excerpt of the faulty code).
which fails with the following error:

File "essai.ml", line 71, characters 5-491:
The abbreviation specElement expands to type
< get_ident : int; get_name : string; mytype : specelement;
  recv : string * comm list -> string * string list -> unit;
  send : comm -> string -> unit; set_ident : int -> unit;
  set_name : string -> unit >
but is used with type < get_ident : int; set_ident : int -> unit; .. >


open Hashtbl;;


type specelement = 
    [`Spec | `Activite | `Conteneur 
  | `Controleur | `ControleParent 
  | `ControleEnfant | `Deploiement 
  | `DeploiementEnfant | `ConfigurationComposite
  | `ExportationService | `DeploiementAgent
  | `DeploiementControleur | `ConfigurationAgent 
  | `ConfigurationControleur | `Attente
  | `ReconfigurationParesseuse | `Configuration
  | `Importation |`Controle | `InstantiationAsynchrone 
  | `Initialisation | `LiaisonTardive | `Referentiel]

class ['a] countingObjects =
  object (this)
    val mutable elements = ([] : 'a list)
   (* Identificateur 0 est non attribue *)
    val mutable id = 0
    method identify x =
      if not (List.memq x elements) then (
	elements <- [x]@elements ;
	id <- id+1 ; x#set_ident id 
       )
   method retrieveObject (id:int) =
      List.find (fun x -> x#get_ident = id) elements
  end


let countingObjects = new countingObjects ;;

type comm = 
    Direct of int
  | ControleurParent
  | Referentiel
  | ComposantControle

class synchronisationAccounting =
  object (this)
    val mutable synchroRecv = create 10
    val mutable synchroSend = create 10
    method private addToTable table cle1 cle2 obj =
      if(not(mem table cle1)) then (
	let ht = create 10 in
 	add ht cle2 obj ;
	add table cle1 ht
       )
      else (
	let ht = find table cle1 in
	if (not(mem ht cle2)) then 
	  add ht cle2 obj
	else
	  let all = find_all ht cle2 in
	  if(not(List.mem obj all)) then
	    add ht cle2 obj
       );
    method send fid tid event =
      this#addToTable synchroSend fid tid event ;
      match (fid,tid) with 
	(Direct idf, Direct idt) -> Printf.fprintf stdout "%s" event 
      |	(_,_) -> failwith "Not yet implemented"
    method recv fidd tid eventd =
      match (fidd,eventd) with 
	((fidn,fidl),(eventn,eventl)) ->
	  List.iter (fun fid -> (List.iter (fun event -> this#addToTable
synchroRecv fid tid event) eventl)) fidl ; 
	  Printf.fprintf stdout "%s %s" eventn fidn ;
  end

let synchroAccounting = new synchronisationAccounting ;;

class specElement =
  fun  (x:specelement)  ->
  object (this)
    val mutable ident = 0
    val mutable name = "" 
    method mytype = x 
    method set_ident id = ident <- id 
    method get_ident = ident
    method set_name x = name <- x
    method get_name = name
    method send tid event = synchroAccounting#send (Direct ident) tid
event
    method recv fid event =  synchroAccounting#recv fid (Direct ident)
event
   
    initializer countingObjects#identify (this:>specElement)
  end


What is the problem ???
It does compile if I comment out send and recv methods of class
specElement.
Any help would be really appreciated.

Best regards,

Frederic Tronel.
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


             reply	other threads:[~2002-04-22  8:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-22  8:43 Frederic Tronel [this message]
2002-04-22 10:10 ` Sami Mäkelä
2002-04-22 21:05 ` John Max Skaller
2002-04-23  7:40   ` Frederic Tronel
2002-04-24  0:36     ` John Max Skaller

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=3CC3CD45.E6D6E166@inrialpes.fr \
    --to=frederic.tronel@inrialpes.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