[wg-camlp4] Structured comments, shallow embeddings and deep quasiquotations
lpw25 at cam.ac.uk
Tue Feb 5 17:22:55 GMT 2013
On Feb 5 2013, Alain Frisch wrote:
>On 02/05/2013 05:35 PM, Leo White wrote:
>> If the extension is part of a module then using it requires you to
>> initialise that whole module at compile-time. This includes initialising
>> (and so potentially executing) code in the module that is intended for
>> To prevent this from happening we can simply not allow extensions to be
>> part of modules. However, we then have no means of referring to that
>> extension. So in order to refer to these extensions we allow them to be
>> members of namespaces.
>I don't follow. The problem, as I see it, is not that code for the
>extension is in *some* module, but that it is in the *same* module as
>the unit on which it needs to apply.
While obviously using an extension from the same module is a problem, it is
not the problem I am talking about.
The problem is that the quotation is in a module that is part of the
program. This module will be initialised at both compile-time and run-time.
Any effects of initialising the module will occur both times. Since an
OCaml program's run-time behaviour is basically defined as the effects of
initialising its modules this will cause confusion and bugs.
By separating the extensions from modules we prevent this almost certainly
undesired behaviour because only modules can be linked into a program.
One of the strong points of the camlp4/ppx model of creating preprocessors
for implementing extensions is that it is very clear what is executed at
compile-time and what is executed at run-time. The ".mlq" files provide
similar clarity to extensions implemented within the language itself.
>Would the code for .mlq would be compiled manually
>before its expanders can be used, or would this compilation happen
They would need to be compiled, just like ".mli" files.
> Which technology would then be used to run this code
>(Dynlink, static linking, toplevel-like technology for in-process
Probably the same technology as the top-level.
More information about the wg-camlp4