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

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-05-02 (09:12)
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 

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


To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: