On Tue, Nov 8, 2011 at 10:10 AM, Gabriel Scherer
<[email protected]> wrote:
> If you want some module of your system to be parametrized by another
> module (to be able to pass either a concrete module or a mockup
> module), you should use a functor.

And if you don't want to pollute your entire code with functor when
it's in fact for testing and not part of the logic of the application,
you can use the "functor of the poor": you put your net_lib.ml in a
"real_src" sub directory, and the mockup net_lib.ml (same name) in
"mockup_src", and then you change wich subdir is in the path. Less
pretty, but less invasive too!

Other dirty option (yerk): you put your net_lib module in a reference
over a first class module, and you dynamically change it to point to
the mockup version when you want to test it (but this will probably
not work in many situations, like with abstract types)

-- 
Caml-list mailing list.  Subscription management and archives:
https://sympa-roc.inria.fr/wws/info/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to