Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Sylvain <Sylvain.Baro@lip6.fr>
To: caml-list@inria.fr
Subject: Typing question
Date: Mon, 25 Oct 1999 17:07:58 +0200 (CEST)	[thread overview]
Message-ID: <Pine.LNX.4.04.9910251706200.10582-100000@samael.ufr-info-p6.jussieu.fr> (raw)

Hello,

I tried to compile this file "foobar.ml" issuing 

ocamlc -c -i foobar.ml > foobar.mli
ocamlc -c -i foobar.mli
ocamlc -c foobar.ml

But at the third stage of the process, it answers me that the
implementation doesn't match the interface ...

I joined the file "as is" in the following, because it is a short one.

-- begin --
(* Name server *)

open Hashtbl


exception EmptyContextAllocation
exception NameAlreadyUsed of string


class virtual answerToIsNewName =
  object 
  method virtual isNewName : string -> bool
end

type nameType =
    ConstrName
  | TypeName
  | PredName
  | VarName
  | MuName


type nameInfo =
    { kind : nameType ; num : int}


(* one table because each  number identificator is unique *)
let (numTable : (int,string) t) =
  create 111


let global_name_cpt = ref 0
let gen_new_global () = 
  incr global_name_cpt ; !global_name_cpt




(* one nameTable should be created for each scope *)
class nameTable (fatherContext : #answerToIsNewName) =
  object(self)
  val table  =
    (create 17 : (string,nameInfo) t)

  val fatherContext  = ((fatherContext) : #answerToIsNewName)

 method newName kindOf  =
    ((let newnum = gen_new_global ()
    in
    let newname = string_of_int newnum (* Temporaire *)
    in
    let register () = 
      add numTable newnum newname ;
      add table newname {kind = kindOf ; num = newnum}
    in
    try
      find table newname ; 
      self#newName kindOf
    with Not_found ->
      (register () ; newname)) : string)
          


  method isNewName n = 
    try 
      find table n ; false
    with Not_found -> fatherContext#isNewName n


  method addName name kindOf =
    let newnum = gen_new_global ()
    in
    let register () = 
      add numTable newnum name ;
      add table name {kind = kindOf ; num = newnum}
    in
    try
      find table name ; 
      raise (NameAlreadyUsed name)
    with Not_found ->
      register ()
   
  method delName name =
    remove table name

end


class emptyContextClass =
  object
  method newName (x : nameType) = ((raise EmptyContextAllocation) :
string)
  method isNewName (s : string) = true
  method addName (n:string) (k:nameType) = 
    ((raise EmptyContextAllocation) : unit)

end

let emptyContext = new emptyContextClass


-- end --

Thank you.

-- 

					Sylvain Baro
					Sylvain.Baro@lip6.fr




             reply	other threads:[~1999-10-25 18:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-10-25 15:07 Sylvain [this message]
1999-10-26  8:02 ` Sven LUTHER
1999-10-26 10:35   ` Sylvain
1999-10-26 18:16 ` skaller
1999-10-28 18:15 ` Jerome Vouillon
2007-04-24 18:14 typing question micha

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=Pine.LNX.4.04.9910251706200.10582-100000@samael.ufr-info-p6.jussieu.fr \
    --to=sylvain.baro@lip6.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