Browse thread
[Caml-list] classes vs modules
-
Tom _
-
Markus Mottl
-
Brian Rogoff
- Markus Mottl
-
Tom _
- Brian Rogoff
- Andreas Rossberg
- Andreas Rossberg
-
Brian Rogoff
-
Markus Mottl
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| 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