[ocaml-platform] on the need and design of OCaml namespaces

Yaron Minsky yminsky at janestreet.com
Mon Feb 25 14:15:27 GMT 2013


On Mon, Feb 25, 2013 at 9:12 AM, Yaron Minsky <yminsky at janestreet.com> wrote:
> On Sun, Feb 24, 2013 at 2:26 PM, Christophe TROESTLER
> <Christophe.Troestler at umons.ac.be> wrote:
>> On Fri, 22 Feb 2013 11:41:10 +0000, Anil Madhavapeddy wrote:
>>>
>>>
>>> There's one scenario which absolutely requires the ability to explicitly
>>> open a particular namespace: camlp4 code generation.
>>>
>>> Right now, several camlp4 extensions break because they use modules from
>>> the standard Pervasives library, and have no way to explicitly state that.
>>> If Core.Std is opened, then compilation fails.
>>>
>>> The two workarounds are:
>>> - hack the build system to pass -pp options to the camlp4 generator.
>>> Painful.
>>> - have some facility to explicitly open 'Caml_std' or 'Core_std' locally,
>>> irrespective of the current module environment.
>>>
>>> I believe namespaces addresses the latter workaround.
>>
>>
>> Camlp4 can insert some code to alias the standard modules needed by code
>> generation at the beginning of the source files (not foolproof because a
>> name needs to be generated but good enough in practice).  It would be better
>> if that facility was provided by a Camlp4 module instead of needing to be
>> redone by each extension.
>
> I like this workaround a lot, and am embarrassed not to have thought
> of it myself...

As a side note, if we were to build such a facility for ppx and/or
camlp4, I'd love for camlp4 extensions to refer to Pervasives
explicitly, and not rely on the assumption that it has been opened.

y


More information about the Platform mailing list