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