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] classes vs modules
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-05-28 (08:34)
From: Andreas Rossberg <rossberg@p...>
Subject: Re: [Caml-list] classes vs modules
Tom _ wrote:
> BTW, I opted for just passing the "lt" function
> as explicit arguments to all the functions in the
> module that need them.  That seems like the most
> general approach, although it means some extra
> arguments and it doesn't guarantee consistency,
> as people might pass incompatible versions of "lt"
> to different calls;

You can avoid this by passing it to the creator
function only and store it inside the object:

	val make_treap : ('a -> 'a -> bool) -> 'a treap

The treap type would look like this:

	type 'a treap' = Empty | ...
	type 'a treap  = {treap' : treap'; lt : 'a -> 'a -> bool}

In most cases I would prefer the functor version, though.

Hope this helps,

	- Andreas

Andreas Rossberg, rossberg@ps.uni-sb.de

"Computer games don't affect kids.
 If Pac Man affected us as kids, we would all be running around in
 darkened rooms, munching pills, and listening to repetitive music."
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr