Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] classes, objects, and class variables
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-11-20 (13:07)
From: Jacques Garrigue <garrigue@k...>
Subject: [Caml-list] classes, objects, and class variables
To whom it may concern,

I'm in the process of improving the ocaml class system.
Principally the following two points:
1) making class creation cheaper.
   If you believed you could create classes in a "let module", and
   get away with it, you weere: it was prohibitively expensive in both
   time and space. Now I'm seeing 10000% speeups.
2) using this to make objects (or final classes) first class.
   Be able to write "let o = object (self) method m = ... end"
   Side advantage, there are no restrictions on polymorphism.

But in this process, I came along with the rather strange behaviour of
class variables. Class variables are defined by a let before any
parameters, for instance
  class c = let a = init () in fun ... -> object ... end
Their current semantics is to be evaluated repeatedly, once for c,
but again for all classes inheriting from c. The problem is that this
is costly for the implementation, doesn't fit well with the
possibility to create dynamically an arbitrary number of classes
inheriting from, and that I don't see what it's intended for.

So I'm planning to revert to the more intuitive semantics: evaluation
when creating c, but never again.

Does that bother anybody?

Jacques Garrigue

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: