From: "T. Kurt Bond" MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16816.53453.797569.169356 at tkb.mpl.com> Date: Fri, 3 Dec 2004 15:47:09 -0500 To: lablgtk at kaba.or.jp Subject: GUtil.memo constraint too restricive? Is there a bug in GUtil.memo? Should the constraint on that class be constraint 'a = instead of constraint 'a = ? Here's a lablgtk2 toplevel session with lablgtk-2.4.0 and O'Caml 3.08.1: Objective Caml version 3.08.1 # let e = GEdit.entry ~text:"some text" ();; val e : GEdit.entry = # let m = new GUtil.memo ();; val m : < get_oid : int > GUtil.memo = # m#add e;; Characters 6-7: m#add e;; ^ This expression has type GEdit.entry but is here used with type < get_oid : int > Only the first object type has a method activates_default # class ['a] nemo () = object constraint 'a = val tbl = Hashtbl.create 7 method add (obj : 'a) = Hashtbl.add tbl obj#get_oid obj method find (obj : GObj.widget) = Hashtbl.find tbl obj#get_oid method remove (obj : GObj.widget) = Hashtbl.remove tbl obj#get_oid end;; class ['a] nemo : unit -> object constraint 'a = < get_oid : int; .. > val tbl : (int, 'a) Hashtbl.t method add : 'a -> unit method find : GObj.widget -> 'a method remove : GObj.widget -> unit end # let n = new nemo ();; val n : < get_oid : int; _.. > nemo = # n#add e;; - : unit = () # n#find e#coerce;; - : GEdit.entry = # Am I missing something obvious? -- T. Kurt Bond, tkb@tkb.mpl.com