From: "Mattias Waldau" <mattias.waldau@tacton.se>
To: "Caml-List" <caml-list@inria.fr>
Subject: "pointers" to methods
Date: Tue, 6 Feb 2001 18:26:33 +0100 [thread overview]
Message-ID: <AAEBJHFJOIPMMIILCEPBKEHCCEAA.mattias.waldau@tacton.se> (raw)
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
next reply other threads:[~2001-02-07 21:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-02-06 17:26 Mattias Waldau [this message]
2001-02-07 22:27 ` John Prevost
2001-02-08 17:00 ` John Max Skaller
2001-02-07 23:23 ` Gerd Stolpmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AAEBJHFJOIPMMIILCEPBKEHCCEAA.mattias.waldau@tacton.se \
--to=mattias.waldau@tacton.se \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox