On Fri, Oct 17, 2008 at 12:15:08PM +0100, Conglun Yao wrote: > I'm just wondering is it possible to use camlp4 to generate more than > one compiled files. > Normally, camlp4 preprocesses a file and then pass it directly to > compiler (for *.cmo), or its pretty-printer (for *.ml or other > 'plain' file). > > In my case, I want to extend the syntax, and write a file, then > preprocess (camlp4) it to generate two different *.cmo files, each one > could be executed separately. > > Is it possible?
Camlp4 extensions can open and write files normally. However it doesn't have access to crucial details of the 'OCaml environment' such as the current search path for libraries, which means that it usually cannot do anything sensible. For example, I wanted to load another module/library from a camlp4 extension - but that sort of thing isn't possible as far as I can tell. I wrote a bit more about this issue here: http://camltastic.blogspot.com/2008/05/persistent-matches-in-pabitmatch.html Rich. -- Richard Jones Red Hat _______________________________________________ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs