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 WAA17135 for caml-red; Wed, 7 Feb 2001 22:05:15 +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 SAA05410 for ; Tue, 6 Feb 2001 18:26:54 +0100 (MET) Received: from mail.pi.se (mail.pi.se [195.7.64.8]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id f16HQr915189 for ; Tue, 6 Feb 2001 18:26:53 +0100 (MET) Received: from gateway ([195.7.85.166]) by mail.pi.se (8.8.8/8.8.8) with SMTP id SAA16176 for ; Tue, 6 Feb 2001 18:26:48 +0100 (MET) From: "Mattias Waldau" To: "Caml-List" Subject: "pointers" to methods Date: Tue, 6 Feb 2001 18:26:33 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Sender: weis@pauillac.inria.fr In the following code I would like to apply the method inc or dec to the object obj. However, what is the syntax I should use? At all comments below the compilation fails. class class1 = object (self) val mutable x = 1 method inc step = x <- x+step method dec step = x <- x+step method get () = x end let main () = let method_to_call = if Random.int 2 = 0 then inc (* pointer to inc-method in class1 *) else dec (* pointer to dec-method in class1 *) in let obj = new class1 in obj#method_to_call 2; (* apply pointer to method in class1 *) obj#get () /mattias