From: David House <dhouse@janestreet.com>
To: Pierre-Etienne Meunier <pierreetienne.meunier@gmail.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Partial module include
Date: Fri, 21 Sep 2012 17:41:14 +0100 [thread overview]
Message-ID: <CAK=fH+gkKcEYy4-MEBYDKUkbm+b==Q1ndUFGQBwnNsGdHUNQfQ@mail.gmail.com> (raw)
In-Reply-To: <3371F9A1-1248-42DC-9761-8A7797A1C1D1@gmail.com>
Sure. That exact code will work just fine.
It's a special case of "shadowing", where bindings override any
previous ones, for the duration of their scope. E.g.:
let x = 5 in
let x = 4 in
(* here x is 4 *)
also:
let x = 5 in
let () =
let x = 4 in
printf "%d " x
in
printf "%d\n" x
Prints "4 5", because the inner binding only has effect during the
time that it is in scope, and afterwards the original binding is
"uncovered" again.
On Fri, Sep 21, 2012 at 5:37 PM, Pierre-Etienne Meunier
<pierreetienne.meunier@gmail.com> wrote:
> Hi,
>
> Is it possible in ocaml to redefine a part of an included module, like in the following code ?
>
> module A=struct
> let a=0
> let b=1
> end
>
> module B=struct
> include A
> let b=2
> end
>
>
> Thanks
> Pierre
> --
> 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
>
next prev parent reply other threads:[~2012-09-21 16:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-21 16:37 Pierre-Etienne Meunier
2012-09-21 16:41 ` David House [this message]
2012-09-21 16:43 ` Pierre-Etienne Meunier
2012-09-21 16:47 ` David House
2012-09-21 16:55 ` Markus Mottl
2012-09-21 17:47 ` Jeremy Yallop
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='CAK=fH+gkKcEYy4-MEBYDKUkbm+b==Q1ndUFGQBwnNsGdHUNQfQ@mail.gmail.com' \
--to=dhouse@janestreet.com \
--cc=caml-list@inria.fr \
--cc=pierreetienne.meunier@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