From: Eijiro Sumii <sumii@lute.is.s.u-tokyo.ac.jp>
To: caml-list@inria.fr
Cc: sumii@lute.is.s.u-tokyo.ac.jp
Subject: dynamic method look-up?
Date: Thu, 02 Apr 1998 19:49:36 +0900 [thread overview]
Message-ID: <199804021049.TAA20435@lute.is.s.u-tokyo.ac.jp> (raw)
Hello, everyone. I'm sorry that I don't write French version. I know
very little about French language. (Though I'm not very good at
English, either.)
I have a question about the implementation of method invocation in
ocaml. Whenever I compile a tiny program like the following one by
ocamlopt with `-S' option (on any platform),
let invoke_foo obj = obj # foo;;
class c1 () =
method foo = 123
end;;
class c2 () =
method foo = 456
method bar = "abc"
end;;
let o1 = new c1 ();;
let o2 = new c2 ();;
print_int ((invoke_foo o1) + (invoke_foo o2));;
print_newline ();;
the assembly code generated by ocamlopt seems to contain an ascii
string "foo" and to use it at runtime. Is the method `foo'
dynamically looked up before its invocation? If it is, isn't there a
more efficient way than dynamic method look-up to implement method
invocation? (something like index passing in Ohori's polymorphic
record calculus [1], or implicitly generating and passing some
fuctions like a coercion function and a put function in Hofmann &
Pierce's positive subtyping [2])
// Eijiro Sumii <sumii@yl.is.s.u-tokyo.ac.jp>
//
// Kobayashi Laboratory, Department of Information Science,
// Faculty of Science, University of Tokyo
[1] Atsushi Ohori. A polymorphic record calculus and its
compilation. ACM Transactions on Programming Languages and Systems,
Vol 17, No 6, Pages 844-895.
[2] @inproceedings (HofmannPierce94a,
author = "Martin Hofmann and Benjamin Pierce" ,
title = "Positive Subtyping",
booktitle = "Proceedings of Twenty-Second Annual ACM Symposium on
Principles of Programming Languages",
year = "1995" ,
month = jan,
publisher = "ACM" ,
pages = "186--197",
note = "Full version in {\em Information and Computation},
volume 126, number 1, April 1996.
Also available as University of Edinburgh technical
report ECS-LFCS-94-303, September 1994."
)
next reply other threads:[~1998-04-03 10:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-04-02 10:49 Eijiro Sumii [this message]
1998-04-06 16:57 ` Didier Remy
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=199804021049.TAA20435@lute.is.s.u-tokyo.ac.jp \
--to=sumii@lute.is.s.u-tokyo.ac.jp \
--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