caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
To: dmitry.bely@gmail.com
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Class runtime representation
Date: Sat, 08 Dec 2007 22:36:48 +0900 (JST)	[thread overview]
Message-ID: <20071208.223648.27836833.garrigue@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <90823c940712070559i5c435a10l76bbb3ec328690aa@mail.gmail.com>

From: "Dmitry Bely" <dmitry.bely@gmail.com>
> Just curious: why Ocaml runtime should know class method names? Why
> the method tag (a hash value computed from the name) is not enough?

Good question.
Names are only used during class construction, which is dynamic in
ocaml. Names are used for methods (both public and private) and
instance variables. Of all those, only public methods use a hashed
values in other operations, and for this reason public methods in the
same class are guaranteed to have no hash conflicts. But this is not
enforced for private methods, which can always be called in a more
direct way. And since some internal data structures mix private and
public methods, it seems simpler to have names for all.

Now, as we can also statically detect potential conflicts between
private methods, it would be possible to use hashed tags for private
methods too (and even instance variables). This might improve code
size, as names would disappear from the runtime. This would not change
performance however, as class construction only occurs once for most
class declarations, and a fixed number of times in more complex
examples combining inheritance and functors. And it would introduce a
new restriction on the naming of private methods.

Another reason names were kept is to eventually allow runtime
introspection. This is not accessible currently, but the runtime knows
the names of all methods in a class.

Jacques Garrigue


  parent reply	other threads:[~2007-12-08 13:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-07 13:59 Dmitry Bely
2007-12-07 14:36 ` [Caml-list] " Till Varoquaux
2007-12-07 15:16   ` Dmitry Bely
2007-12-08 13:36 ` Jacques Garrigue [this message]
2007-12-10 14:00   ` Dmitry Bely
2007-12-10 15:51     ` Richard Jones
2007-12-10 17:19       ` Dmitry Bely

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=20071208.223648.27836833.garrigue@math.nagoya-u.ac.jp \
    --to=garrigue@math.nagoya-u.ac.jp \
    --cc=caml-list@inria.fr \
    --cc=dmitry.bely@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).