[wg-camlp4] Structured comments, shallow embeddings and deep quasiquotations
alain.frisch at lexifi.com
Tue Feb 5 17:39:44 GMT 2013
On 02/05/2013 06:22 PM, Leo White wrote:
> 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.
As I see it, the problem is not that the code for the extension is in a
module, but that it is in a module which will be linked with your target
program. You propose to avoid any such potential confusion by
segregating those modules which contain extension code from other
"regular modules". Conceptually, this is not very different than
choosing a module prefix (e.g. "pb_", the successor of "pa_") and simply
ensuring in the compiler that they refuse to link pb_* modules into
programs; those module can only be loaded (dynamically?) in a specific
context (a particular "ppx" driver). It's just that you declare that
these pb_* units are not real modules (and introduce a specific file
extension instead of a prefix).
But fundamentally, I still don't agree that there is a clear separation
between "extension code" and "program code". In particular, an
extension might very well use a third-party library (e.g. an XML parser)
or share some code with the target program. Why should we enforce a
strong separation, in particular if this implies some ad hoc rules in
> >> Would the code for .mlq would be compiled manually before its
>> expanders can be used, or would this compilation happen automatically?
> They would need to be compiled, just like ".mli" files.
They contain code, so I guess you meant: just like ".ml" files?
>> Which technology would then be used to run this code (Dynlink, static
>> linking, toplevel-like technology for in-process compilation/execution)?
> Probably the same technology as the top-level.
This seems to contradict the "need to be compiled" above.
More information about the wg-camlp4