From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id AF9C1BBCA for ; Tue, 26 Feb 2008 13:14:55 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAFeRw0fAXQImh2dsb2JhbACQZAEBAQgKKZty X-IronPort-AV: E=Sophos;i="4.25,407,1199660400"; d="scan'208";a="8601150" Received: from discorde.inria.fr ([192.93.2.38]) by mail1-smtp-roc.national.inria.fr with ESMTP; 26 Feb 2008 13:14:55 +0100 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id m1QCEq8j026000 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Tue, 26 Feb 2008 13:14:55 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAN6Qw0dQRFuwh2dsb2JhbACQZAEBAQgKKZtx X-IronPort-AV: E=Sophos;i="4.25,407,1199660400"; d="scan'208";a="9605629" Received: from furbychan.cocan.org ([80.68.91.176]) by mail3-smtp-sop.national.inria.fr with ESMTP; 26 Feb 2008 13:14:52 +0100 Received: from rich by furbychan.cocan.org with local (Exim 4.63) (envelope-from ) id 1JTyhv-0005Tt-Cr; Tue, 26 Feb 2008 12:14:51 +0000 Date: Tue, 26 Feb 2008 12:14:51 +0000 To: Berke Durak Cc: Caml-list List Subject: Re: [Caml-list] Objects, dynamic cast, Obj.magic abuse and dragons Message-ID: <20080226121451.GA20860@annexia.org> References: <47C3F96E.4080901@exalead.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <47C3F96E.4080901@exalead.com> User-Agent: Mutt/1.5.13 (2006-08-11) From: Richard Jones X-Miltered: at discorde with ID 47C402BD.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; 0100,:01 berke:01 durak:01 lablgtk:01 val:01 hashtbl:01 hashtbl:01 gtk:01 26,:98 hero:98 wrote:01 caml-list:01 constraint:01 objects:02 widget:03 On Tue, Feb 26, 2008 at 12:35:10PM +0100, Berke Durak wrote: > The problem is that the main game loop gets the current location by taking > the container of the hero... which is a physical. However, it needs to > call the place-specific method "go". I only briefly read over this, but maybe the thing you want is an object memo. There's a specialized one in lablgtk called GUtil.memo, but the basic source for it could be adapted: class ['a] memo () = object constraint 'a = #widget val tbl = Hashtbl.create 7 method add (obj : 'a) = Hashtbl.add tbl obj#get_id obj method find (obj : widget) = Hashtbl.find tbl obj#get_id method remove (obj : widget) = Hashtbl.remove tbl obj#get_id end There's an example of using this if you search down for 'memo' on this page: http://www.ocaml-tutorial.org/introduction_to_gtk Rich. -- Richard Jones Red Hat