From: Jordo <jordojw@gmail.com>
To: Leo White <lpw25@cam.ac.uk>
Cc: "caml-list@inria.fr" <caml-list@inria.fr>
Subject: Re: [Caml-list] Module aliases ideal name-spacing
Date: Sun, 28 Dec 2014 12:34:15 -0800 [thread overview]
Message-ID: <996F18A3-E87B-4723-A355-25A09AF4527B@gmail.com> (raw)
In-Reply-To: <87d273ljxp.fsf@study.localdomain>
Thank you for the reply, Leo. One of the requirements was that developers be able to name their internal modules as they see fit without having to fear naming collisions. It's also required that file names correspond directly to module names (or at least we retain the capability to do so). It appears in this solution you suggested, developers still must prefix their file names in order to avoid collisions. That is unintuitive because it's not always clear why a file is named differently than its namespaced alias. Readers must examine the module alias file to know which file a module is implemented in. Packs provided a solution to this and I'm hoping we may continue that highly effective pattern while also enjoying the benefits of module aliases. Having the freedom to name modules without fear of collision outside of your "project" seems strictly better than having to be concerned about collisions outside of your project. Is there any sequence of compilation commands that will guard these namespaces as I've been successfully doing with packs? Could the proper solution be to actually have packs use module aliases? That might allow *proper* namespacing along with the compilation benefits of aliases. Is there any other way?
I
On Dec 28, 2014, at 10:15 AM, Leo White <lpw25@cam.ac.uk> wrote:
>> One set of modules that form a kind of namespaced "project" MyLib.
>> ---------
>>
>> ~/myLib/myModule.ml
>> open MyLib (* This is not needed - short names are same as long *)
>> (* Sees Utils belonging to MyLib *)
>>
>> ~/myLib/utils.ml
>> open MyLib (* This is not needed - short names are same as long *)
>>
>> ~/myLib/myLib.mli and ~/myLib/myLib.ml
>> module MyModule = MyModule
>> module Utils = Utils
>>
>> Another set of modules ("project") that depends on the previous project YourLib
>> ---------
>>
>> ~/yourLib/yourModule.ml
>> open YourLib (* This is not needed - short names are same as long *)
>> (* Sees Utils belonging to YourLib *)
>>
>> ~/yourLib/utils.ml
>> open YourLib (* This is not needed - short names are same as long *)
>>
>> ~/yourLib/yourLib.mli and ~/yourLib/yourLib.ml
>> module YourModule = YourModule
>> module Utils = Utils
>>
>> Finally, an application "project" that uses the namespaces generated by the previous two projects
>> ---------
>>
>> ~/myApp/myApp.ml
>> let x = MyLib.Utils.x + YourLib.Utils.y
>
> You can use the `-o` and `-open` command-line options to get the
> behaviour you are after. If you change myLib/myLib.ml(i) to be
>
> module MyModule = MyLibMyModule
> module Utils = MyLibUtils
>
> and make similar changes to yourLib/yourLib.ml(i), then you can use the
> following commands:
>
> cd ~/myLib
> ocamlc -no-alias-deps myLib.mli
> ocamlc -no-alias-deps myLib.ml
> ocamlc -c -open MyLib -o myLibUtils.cmo utils.ml
> ocamlc -c -open MyLib -o myLibMyModule.cmo myModule.ml
>
> cd ~/yourLib
> ocamlc -c -no-alias-deps yourLib.mli
> ocamlc -c -no-alias-deps yourLib.ml
> ocamlc -c -open YourLib -o yourLibUtils.cmo utils.ml
> ocamlc -c -open YourLib -o yourLibYourModule.cmo yourModule.ml
>
> cd ~/myApp
> ocamlc -c -I ../myLib -I ../yourLib myApp.ml
>
> Setting up this compilation scheme in your build system might be a bit
> of effort, but it should work.
>
> Regards,
>
> Leo
next prev parent reply other threads:[~2014-12-28 20:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-27 23:04 Jordan W
2014-12-28 18:15 ` Leo White
2014-12-28 20:34 ` Jordo [this message]
2014-12-28 21:26 ` Leo White
2014-12-28 23:25 ` Jordan W
2014-12-29 0:14 ` Leo White
2015-01-07 15:15 ` Goswin von Brederlow
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=996F18A3-E87B-4723-A355-25A09AF4527B@gmail.com \
--to=jordojw@gmail.com \
--cc=caml-list@inria.fr \
--cc=lpw25@cam.ac.uk \
/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