caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* OO programming
@ 2008-02-21  9:31 Tiphaine Turpin
  2008-02-21  9:42 ` [Caml-list] " Erik de Castro Lopo
                   ` (3 more replies)
  0 siblings, 4 replies; 32+ messages in thread
From: Tiphaine Turpin @ 2008-02-21  9:31 UTC (permalink / raw)
  To: caml-list

Hello,

After a few unsuccessfull tries with using the object oriented features 
of ocaml, I have been looking for ways to write classes that have a 
chance to typecheck. The usual problem is that objects refer to other 
objects, those objects may refer back to objects referring to them, then 
objects refer to different objects, some of them having more methods 
than others (subtyping), etc. and finally the programmer has to give a 
type to all those beautifull mutable fields that are not fully 
specified, or make them parametric. Of course, the resulting classes 
should be reusable, that is, one should be able to extend a collection 
of related classes simultaneously, such that the fields now have the 
relevant subtype instead of the type they had before.

The best guidelines that I found are in the following course from Didier 
Remy :

http://caml.inria.fr/pub/docs/u3-ocaml/ocaml-objects.html#toc13

He uses parametric classes  (parametric in the type of the related 
objects) so that they can be extended. However I'm still unsatisfied 
with this solution, because the related classes are written 
independently, or, more precisely, their dependencies remain in the head 
of the programmer and have no concretization in the language. For 
example if a class refer to a method provided by a related class, this 
way of writing them does not guarantee that the method is actually 
defined. Only when creating and linking the objects together will the 
type-checker reject the program, if for example, the method has been 
misspelled in one class. So for me this coding scheme has the drawback 
that it unplugs the type-checker and just call it at the end. For me the 
"ideal" use of objects would use mutually recursive classes with fields 
defined with a type referring to the name of the other class. The 
problem is that simply using the closed type of the other classs often 
prevent any further refinement.

Hence my question: does anyone knows a way of combining the reusability 
of sets of related classes with a more modular (type/consistency)-checking ?

Tiphaine Turpin

P.S. : Sorry for not providing any example myself ; the above link has 
very clear ones, that express exactly what I mean.


^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2008-03-04 14:00 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-21  9:31 OO programming Tiphaine Turpin
2008-02-21  9:42 ` [Caml-list] " Erik de Castro Lopo
2008-02-21 13:38 ` Remi Vanicat
2008-02-24 16:33 ` [Caml-list] " Dirk Thierbach
2008-02-25  9:23   ` Tiphaine.Turpin
2008-02-25 15:48     ` Edgar Friendly
2008-02-25 16:02       ` Berke Durak
2008-02-25 20:12         ` Dirk Thierbach
2008-02-25 20:51           ` Tiphaine.Turpin
2008-02-25 23:03             ` Dirk Thierbach
2008-02-25 20:10     ` Dirk Thierbach
2008-02-25 21:49       ` Tiphaine.Turpin
2008-02-25 23:07         ` Dirk Thierbach
2008-02-29 14:22       ` Tiphaine.Turpin
2008-02-26  6:17 ` Jacques Garrigue
2008-02-26  9:36   ` Julien Signoles
2008-02-27  0:25   ` Tiphaine.Turpin
2008-02-27  1:37     ` Jacques Garrigue
2008-02-28  8:34       ` Keiko Nakata
2008-02-28 13:30         ` Andrej Bauer
2008-02-28 15:18           ` Keiko Nakata
2008-02-28 16:02           ` Edgar Friendly
2008-02-29 14:35         ` Tiphaine.Turpin
2008-02-29 15:58           ` Keiko Nakata
2008-03-03  9:40             ` Tiphaine.Turpin
2008-03-03 10:20               ` Jacques Garrigue
2008-03-03 10:30                 ` Tiphaine.Turpin
2008-03-03 15:18               ` Keiko Nakata
2008-03-03 19:25                 ` Tiphaine Turpin
2008-03-04 14:00                   ` Keiko Nakata
2008-02-27  7:40     ` Dirk Thierbach
2008-02-27 14:04       ` Tiphaine.Turpin

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).