On Dec 8, 2007 4:36 PM, Jacques Garrigue <garrigue@math.nagoya-u.ac.jp> wrote:
> 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.
Thanks for the detailed explanation. I don't like method names in the
binary because they show some implementation details that I would like
to hide; several extra bytes of code are really not a problem.
- Dmitry Bely