Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Functors
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jon Harrop <jdh30@c...>
Subject: [Caml-list] Functors

Could Set (and others) be implemented polymorphically by using a comparison 
function passed as an argument?

If so, what would be the implications of this approach? I think: you couldn't 
use the type checker to enforce consistent comparison functions between two 
different sets which were, say, being merged. I think you can enforce this 
using the functor approach provided the Sets came from the same functor 
"instantiation".

Functors appear to be somewhat similar to templates in C++. Does the functor 
approach produce more efficient code as it is partially specialised over the 
comparison function?

Also, can functors map to functors as well as modules? If so, code could be 
progressively specialised...

Cheers,
Jon.

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