From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA28820; Wed, 31 Mar 2004 11:18:25 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id LAA28205 for ; Wed, 31 Mar 2004 11:18:25 +0200 (MET DST) Received: from smtp1.adl2.internode.on.net (smtp1.adl2.internode.on.net [203.16.214.181]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i2V9IMYM018000 for ; Wed, 31 Mar 2004 11:18:23 +0200 Received: from [192.168.1.200] (ppp113-158.lns1.syd3.internode.on.net [150.101.113.158]) by smtp1.adl2.internode.on.net (8.12.9/8.12.9) with ESMTP id i2V9IFwn065487 for ; Wed, 31 Mar 2004 18:48:20 +0930 (CST) Subject: [Caml-list] Delegation From: skaller Reply-To: skaller@users.sourceforge.net To: caml-list Content-Type: text/plain Message-Id: <1080724695.13269.156.camel@pelican.wigram> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 31 Mar 2004 19:18:15 +1000 Content-Transfer-Encoding: 7bit X-Miltered: at concorde by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; sourceforge:01 functor:01 'foo':01 instantiate:01 functor:01 passing:01 struct:01 val:01 renaming:01 delegates:01 reordering:01 fiddling:01 9660:01 glebe:01 nsw:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk With the module system, I can write a functor requiring a function called 'foo' with some signature. When I instantiate the functor I can construct a module argument 'on the fly' to rename any function I'm passing like: let g () = ... module M = F (struct val f = g end) So that the names used in the functor are arbitrary and can bind to any entity with suitable renaming. [At least I gather this is the intent] Is there a way to do this with classes? A typical problem is: our class actually has the correct methods, but they're named wrong. A extension is: we have the right method, except the argument order is different. An extension of that is: we don't have exactly the right methods, but we can easily construct them. All these cases can easily be solved with a proxy object that delegates most of the method calls, perhaps with some argument reordering or minor fiddling. But is there a convenient way to construct such objects anonymously at the point needed? After all class types are signature based .. Hmmm.. can I write: (fun o -> object method f: init = o#g end)#f given o has a method g of suitable type but wrong name? -- John Skaller, mailto:skaller@users.sf.net voice: 061-2-9660-0850, snail: PO BOX 401 Glebe NSW 2037 Australia Checkout the Felix programming language http://felix.sf.net ------------------- 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