From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id UAA28886 for caml-red; Thu, 8 Feb 2001 20:04:01 +0100 (MET) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id SAA23284 for ; Thu, 8 Feb 2001 18:05:38 +0100 (MET) Received: from localhost.localdomain (jimbo57.zip.com.au [202.7.88.57]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id f18H5ZH05828 for ; Thu, 8 Feb 2001 18:05:36 +0100 (MET) Received: from ozemail.com.au (IDENT:root@localhost [127.0.0.1]) by localhost.localdomain (8.9.3/8.8.7) with ESMTP id EAA04440; Fri, 9 Feb 2001 04:00:43 +1100 Message-ID: <3A82D0BB.DC0D8AA3@ozemail.com.au> Date: Fri, 09 Feb 2001 04:00:43 +1100 From: John Max Skaller X-Mailer: Mozilla 4.7 [en] (X11; I; Linux 2.2.12-20 i686) X-Accept-Language: en MIME-Version: 1.0 To: John Prevost CC: Mattias Waldau , Caml-List Subject: Re: "pointers" to methods References: <87n1by3z9i.fsf@elbereth.pgh.arsdigita.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: weis@pauillac.inria.fr John Prevost wrote: > let call_method = > if Random.int 2 = 0 then > fun x -> x #inc > else > fun x -> x #dec > in > let obj = new class1 in > call_method obj 2; > obj #get () > > You can't reference a method name explicitly, but you can create a > function that calls that method. Oh! This is a beautiful demonstration of the power of the Ocaml language. Now I will add something: this construction is MORE powerful than C++ pointers to members, which do not form an algbraically complete system because they cannot be composed. But the ocaml ones can be! -- John (Max) Skaller, mailto:skaller@maxtal.com.au 10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850 checkout Vyper http://Vyper.sourceforge.net download Interscript http://Interscript.sourceforge.net