caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Alexandre Pilkiewicz <alexandre.pilkiewicz@polytechnique.org>
To: Hans Ole Rafaelsen <hrafaelsen@gmail.com>, caml-list@inria.fr
Subject: Re: [Caml-list] Include question
Date: Tue, 8 Nov 2011 10:49:38 -0500	[thread overview]
Message-ID: <CAH2fdNYYG8bP72HHmR8p6K5OtC6GpX7NTVc3F+ZURtFnrmig7w@mail.gmail.com> (raw)
In-Reply-To: <CAPFanBHLH56cUqcJF3XLXDHgLAFxa16ZSPCQfoEh4fTawVuzPg@mail.gmail.com>

On Tue, Nov 8, 2011 at 10:10 AM, Gabriel Scherer
<gabriel.scherer@gmail.com> 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)

  parent reply	other threads:[~2011-11-08 15:50 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-08 15:03 Hans Ole Rafaelsen
2011-11-08 15:10 ` Gabriel Scherer
2011-11-08 15:45   ` Hans Ole Rafaelsen
2011-11-08 15:50     ` Thomas Gazagnaire
2011-11-08 15:49   ` Alexandre Pilkiewicz [this message]
2011-11-09  7:29     ` Cedric Cellier
2011-11-09 15:41       ` Vincent Aravantinos
2011-11-09 15:50         ` Vincent Aravantinos
2011-11-09 16:29           ` rossberg
2011-11-09 17:08             ` Vincent Aravantinos
2011-11-09 23:36             ` Jacques Garrigue
2011-11-10 12:08               ` rossberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAH2fdNYYG8bP72HHmR8p6K5OtC6GpX7NTVc3F+ZURtFnrmig7w@mail.gmail.com \
    --to=alexandre.pilkiewicz@polytechnique.org \
    --cc=caml-list@inria.fr \
    --cc=hrafaelsen@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).