From: David House <dhouse@janestreet.com>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Importing specific names
Date: Fri, 26 Oct 2012 12:30:26 +0100 [thread overview]
Message-ID: <CAK=fH+gnN5VXwmKM3Rq9GYmPUYw8-RN7R3NsT5YJL1gh-bia7w@mail.gmail.com> (raw)
In-Reply-To: <CAK=fH+gBymshw-NLQNsw4u04fjjzZOaO04khhk+NbsuqfNFuww@mail.gmail.com>
I should add: although this is possible, I generally find it easier to
read code that has been written with as few opens as possible.
If you find you are using things from Module a lot, you might consider
creating a module alias:
module Mod = Very_long_module_name
You can then say Mod.foo, Mod.bar etc. This makes it obvious where foo
and bar come from, but you don't have to sacrifice readability by
typing such a long module name every time.
(Of course, there is an art to picking module abbreviations as well; I
find it best to pick a short abbreviation which holds at least some
meaning, rather than just "let module M = ...". E.g.:
module Str = My_super_duper_string_module
Rather than:
module S = My_super_duper_string_module
)
Yet another option is to do a local module alias ("let module Mod =
... in"), or a local open ("let open ... in"), in the function(s)
where you need access to things from Module. This keeps things as
localised as possible, which again increases readability. (You only
have to remember the meaning of a module alias for a very short time,
rather than for the scope of the whole module.)
On Fri, Oct 26, 2012 at 12:26 PM, David House <dhouse@janestreet.com> wrote:
> If you want to list the things you want, rather than listing the
> things you don't want, what's wrong with the following?
>
> let x = Module.x
> let y = Module.y
> ...
>
> You could abbreviate that somewhat:
>
> include (struct
> open Module
> let x = x
> let y = y
> ...
> end)
>
> On Fri, Oct 26, 2012 at 12:26 PM, José Romildo Malaquias
> <j.romildo@gmail.com> wrote:
>> Hello.
>>
>> It seems that the expression ocaml "open module-path" exposes all names
>> exported by module-path.
>>
>> Is there any way of exposing only a restrict set of names from a
>> module-path, instead of all names?
>>
>> Romildo
>>
>> --
>> Caml-list mailing list. Subscription management and archives:
>> https://sympa.inria.fr/sympa/arc/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-10-26 11:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-26 11:26 José Romildo Malaquias
2012-10-26 11:26 ` David House
2012-10-26 11:30 ` David House [this message]
2012-10-26 17:45 ` José Romildo Malaquias
2012-10-26 13:55 ` Matthieu Dubuget
2012-10-26 17:51 ` José Romildo Malaquias
2012-10-26 14:48 ` Edgar Friendly
2012-10-26 15:20 ` Yaron Minsky
2012-10-26 17:56 ` José Romildo Malaquias
2012-10-26 15:26 ` Didier Cassirame
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+gnN5VXwmKM3Rq9GYmPUYw8-RN7R3NsT5YJL1gh-bia7w@mail.gmail.com' \
--to=dhouse@janestreet.com \
--cc=caml-list@inria.fr \
/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