English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] Objects or modules ?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-06-29 (01:06)
From: Nicolas FRANCOIS <nicolas.francois@f...>
Subject: [Caml-list] Objects or modules ?
I'd like to make a library managing mathematical data structures, for
example integers, polynoms, fractions, and more if anyone is interested. I
started on the module point of view, mainly to learn how to use modules
and functors. So this is the structure I have :

Ordered_Ring : module managing basic rings operations
Rationnals : Num rationnals adapted to Ordered_Ring
Polynoms : functor taking an ordered ring S in argument to make a module
managing S[x]
Q_polynoms : polynoms over rationnals.

But I see things differently now, mainly because I realized S[x] is an
euclidian ring just as S is, so they should inherit the same module, and
have common operations ((extended) Euclide, square_free factorization...).
in fact I realized this when I started writing my second gcd function.

So my point of view is now :

Euclidian_Ring : Functor taking a ring signature (data structure, basic
operation + and *, link with Z and Q...), and constructing an euclidian
ring with tools.
Rationnals : Euclidian_Ring(Sig_Num)
Sig_Pol : Functor constructing an abstract polynom module sig
Polynom : functor constructing a ring S[x] provided a ring S

Do you think this plan is correct ? Should I translate it to objects ? Is
there some drawbacks using modules or objects ?

Thanks for reading.



                   Nicolas FRANCOIS
 A TRUE Klingon programmer does NOT comment his code
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners