English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] Passing self to a new object
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-10-28 (14:58)
From: Andrew Lawson <andrew@a...>
Subject: [Caml-list] Passing self to a new object
Hi all
	I'm writing a gui program where the callback for a button
creates a new object (also a gui) and needs to pass it a reference to
itself in order that the new object can contact the original for
information. The classes look something like this;

class xyz = 
	let top = ... in
	let ... = ... in
	let btnNew  = ... ~command:(fun () = new abc self) top in
	object (self)

class abc (parent:xyz) =
	object (self)
	var myparent = parent

	My error is;

This expression has type
  < btnDelete : 'a; btnEdit : 'b; btnExit : 'c; btnFind : 'd;
    btnNew : Widget.button Widget.widget; get_config : 'e -> 'f;
    list_record_directory : 'g; new_filename : 'h; read_configuration :
    self : 'j; set_config : 'k -> 'l -> 'm; topLevel : 'n; .. >
but is here used with type 'j
Self type cannot escape its class

	And I have no clue what I am doing wrong :)

		All suggestions appreciated



   Andrew Lawson
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr