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 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,

"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  Archives: