caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] canonical camlp4-suffix?
@ 2001-09-03 15:58 Markus Mottl
  2001-09-03 16:31 ` Clement Renard
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Markus Mottl @ 2001-09-03 15:58 UTC (permalink / raw)
  To: OCAML

Hello,

since I am currently trying to add support for the camlp4-preprocessor
to OcamlMakefile, I'd like to know what people usually use as suffix
for files that should be preprocessed.

Would '.p4' and '.p4i' be ok for modules and module interfaces
respectively? Or are there any other naming conventions used by hardcore
camlp4ers?

Regards,
Markus Mottl

-- 
Markus Mottl                                             markus@oefai.at
Austrian Research Institute
for Artificial Intelligence                  http://www.oefai.at/~markus
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] canonical camlp4-suffix?
  2001-09-03 15:58 [Caml-list] canonical camlp4-suffix? Markus Mottl
@ 2001-09-03 16:31 ` Clement Renard
       [not found] ` <Pine.BSF.3.96.1010903120605.42306B-100000@fledge.watson.org>
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Clement Renard @ 2001-09-03 16:31 UTC (permalink / raw)
  To: Markus Mottl; +Cc: OCAML

On Mon, 3 Sep 2001, Markus Mottl wrote:

> Hello,
> 
> since I am currently trying to add support for the camlp4-preprocessor
> to OcamlMakefile, I'd like to know what people usually use as suffix
> for files that should be preprocessed.
> 
> Would '.p4' and '.p4i' be ok for modules and module interfaces
> respectively? Or are there any other naming conventions used by hardcore
> camlp4ers?
> 
> Regards,
> Markus Mottl

For modules, we usually use .ml4 but I don't know if there a convention
for module interfaces.

Clement Renard

-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] canonical camlp4-suffix?
       [not found] ` <Pine.BSF.3.96.1010903120605.42306B-100000@fledge.watson.org>
@ 2001-09-03 16:36   ` Markus Mottl
  0 siblings, 0 replies; 7+ messages in thread
From: Markus Mottl @ 2001-09-03 16:36 UTC (permalink / raw)
  To: Patrick M Doane; +Cc: OCAML

On Mon, 03 Sep 2001, Patrick M Doane wrote:
> I'm curious - are you going to allow each file to be compiled with
> its own set of camlp4 preprocessors or will it be one set for the
> whole project?

It is always possible for users to provide specific 'make'-rules for
specific files, e.g. when they want to preprocess their OCaml-files in
funny ways. So I don't think it would be a good idea to make things this
complicated.

The main problem is that files containing quotations or syntax extensions
may themselves require preprocessing (e.g. the latter always need this).
It's impossible for 'make' to figure out how to proceed in the general
case. Therefore, I'll only support "first-order" preprocessing with
additional preprocessing flags as required for syntax extensions.

Furthermore, it would be also quite complicated if I supported
implementations of quotations / syntax extensions that spread over several
modules. This would require dependency analysis again. In such difficult
cases the user would be better advised to compile these extensions in
a separate directory and just pass the resulting library to camlp4 via
a flag variable.

I think this scheme should be good enough for most cases. Most people
won't require much more than a couple of quotation files, but don't want
to fiddle around with command line parameters.

Thus, there will only be one list containing all modules that implement
quotations or syntax extensions. They will be compiled before all other
modules and passed to the preprocessor during compilation of the source
files that use the extensions.

> I've seen .mlp sometimes...

Ok, '.mlp' and '.mlip' would be fine for me, too. Any objections?

Regards,
Markus Mottl

-- 
Markus Mottl                                             markus@oefai.at
Austrian Research Institute
for Artificial Intelligence                  http://www.oefai.at/~markus
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] canonical camlp4-suffix?
       [not found] ` <FLELJKKJEIKNBDJGMIHKGEFKCAAA.franka@cs.uu.nl>
@ 2001-09-03 20:26   ` Markus Mottl
  0 siblings, 0 replies; 7+ messages in thread
From: Markus Mottl @ 2001-09-03 20:26 UTC (permalink / raw)
  To: Frank Atanassow; +Cc: OCAML

On Mon, 03 Sep 2001, Frank Atanassow wrote:
> Since you have to know the syntax in question to use camlp4, .p4 and
> .p4i extensions alone are not very useful. I think I used to just call
> them .ml and .mli, but I put a comment at the top of each file with the
> options to pass to ocamlc and camlp4, and sed'd them in my Makefiles.

Sounds flexible, but a bit tricky. It might also slow down the compile
process a bit.

If you already have such a Makefile, I'd be grateful if you could send
it to me so that I can unscrupulously steal whatever seems fitting... 8-)

What does Daniel think? What would be the best way to automate the
application of camlp4?

Regards,
Markus Mottl

-- 
Markus Mottl                                             markus@oefai.at
Austrian Research Institute
for Artificial Intelligence                  http://www.oefai.at/~markus
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] canonical camlp4-suffix?
  2001-09-03 15:58 [Caml-list] canonical camlp4-suffix? Markus Mottl
                   ` (2 preceding siblings ...)
       [not found] ` <FLELJKKJEIKNBDJGMIHKGEFKCAAA.franka@cs.uu.nl>
@ 2001-09-04  6:20 ` Daniel de Rauglaudre
  2001-09-04 12:43   ` Markus Mottl
  3 siblings, 1 reply; 7+ messages in thread
From: Daniel de Rauglaudre @ 2001-09-04  6:20 UTC (permalink / raw)
  To: Markus Mottl; +Cc: OCAML

Hi,

On Mon, Sep 03, 2001 at 05:58:40PM +0200, Markus Mottl wrote:

> since I am currently trying to add support for the camlp4-preprocessor
> to OcamlMakefile, I'd like to know what people usually use as suffix
> for files that should be preprocessed.

I generally prefer using ".ml" and ".mli" because some tools of the
compiler does not accept different suffixes (e.g. the debugger). For
the rules, there are two methods:

1/ add in source files comments specifying how compile the file; in the
   Makefiles, call a shell script reading this comment and launching the
   good command; it is the method I use in the sources of Camlp4 (see the
   files tools/Makefile.tpl and tools/camlp4_comm.sh in Camlp4 sources) and
   in GeneWeb (same kind of shell script): this shell just calls ocamlc
   without -pp parameter if the comment is not found.

2/ compile all files with "-pp camlp4o" (or "-pp camlp4r" if you prefer
   the revised syntax) and use "#load" in your files: this has been possible
   (however not yet documented) since some versions of Camlp4. For example,
   if you use to compile "foo.ml" by:
        ocamlc -pp "camlp4o pa_extend.cmo q_MLast.cmo" -c foo.ml
   you can add in the beginning of foo.ml:
        #load "pa_extend.cmo";;
        #load "q_MLast.cmo";;
   and compile with
        ocamlc -pp camlp4o -c foo.ml

   (double semicolons at end of #load are mandatory; in revised syntax
   use simple semicolon)

   You can also use "#directory" in your source files, doing the same
   thing than the option -I of camlp4.

-- 
Daniel de RAUGLAUDRE
daniel.de_rauglaudre@inria.fr
http://cristal.inria.fr/~ddr/
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] canonical camlp4-suffix?
  2001-09-04  6:20 ` Daniel de Rauglaudre
@ 2001-09-04 12:43   ` Markus Mottl
  2001-09-04 14:00     ` Daniel de Rauglaudre
  0 siblings, 1 reply; 7+ messages in thread
From: Markus Mottl @ 2001-09-04 12:43 UTC (permalink / raw)
  To: Daniel de Rauglaudre; +Cc: OCAML

On Tue, 04 Sep 2001, Daniel de Rauglaudre wrote:
> On Mon, Sep 03, 2001 at 05:58:40PM +0200, Markus Mottl wrote: I
> generally prefer using ".ml" and ".mli" because some tools of the
> compiler does not accept different suffixes (e.g. the debugger). For
> the rules, there are two methods:

Thanks, this is important to know! I don't want to have nasty side
effects when using a non-standard suffix so I'll stay with ".ml" and
".mli" and scan the file for suitable preprocessing options.

> 1/ add in source files comments specifying how compile the file; in the
>    Makefiles, call a shell script reading this comment and launching
>    the good command; it is the method I use in the sources of Camlp4
>    (see the files tools/Makefile.tpl and tools/camlp4_comm.sh in Camlp4
>    sources) and in GeneWeb (same kind of shell script): this shell
>    just calls ocamlc without -pp parameter if the comment is not found.

Ok, I had something like this in mind. Good to know where to find an
example implementation.

> 2/ compile all files with "-pp camlp4o" (or "-pp camlp4r" if you prefer
>    the revised syntax) and use "#load" in your files: this has been possible
>    (however not yet documented) since some versions of Camlp4. For example,

Nice! Though, if I already have to check for a preprocessing tag anyway,
I could also do things as follows:

The topmost line in a file could read like this:

  (*pp camlp4o -I some_dir some_quots.cmo some_more_quots.cmo *)

Then I just check for the 'pp' tag, and if it's there, I just take the
contents of the comment as parameter for the -pp option. This could then
also be a completely different preprocessor (cpp? ;).

Please tell me, if there is any hidden catch with this approach.
Thanks for the hints!

Regards,
Markus Mottl

-- 
Markus Mottl                                             markus@oefai.at
Austrian Research Institute
for Artificial Intelligence                  http://www.oefai.at/~markus
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Caml-list] canonical camlp4-suffix?
  2001-09-04 12:43   ` Markus Mottl
@ 2001-09-04 14:00     ` Daniel de Rauglaudre
  0 siblings, 0 replies; 7+ messages in thread
From: Daniel de Rauglaudre @ 2001-09-04 14:00 UTC (permalink / raw)
  To: Markus Mottl; +Cc: OCAML

Hi,

On Tue, Sep 04, 2001 at 02:43:35PM +0200, Markus Mottl wrote:

> The topmost line in a file could read like this:
>   (*pp camlp4o -I some_dir some_quots.cmo some_more_quots.cmo *)

It is almost my syntax! I use just:
   (* camlp4o -I some_dir some_quots.cmo some_more_quots.cmo *)

Therefore my shell script tests "(* camlp4o" in my source file with a simple
grep. With some appropriate "sed", I build the right command lines. And I
have also a "depend" entry which tests the .cmo files of this line to
create the dependencies.

> Then I just check for the 'pp' tag, and if it's there, I just take the
> contents of the comment as parameter for the -pp option. This could then
> also be a completely different preprocessor (cpp? ;).

Yes. If you need other preprocessors, you can do that. You can take the
version in camlp4 (tools/camlp4_comm.sh) or take the ideas in it, if you
want, no problem. It is implementable, since all compilation of camlp4
files use that (including the files not to be preprocessed).

-- 
Daniel de RAUGLAUDRE
daniel.de_rauglaudre@inria.fr
http://cristal.inria.fr/~ddr/
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2001-09-06 10:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-09-03 15:58 [Caml-list] canonical camlp4-suffix? Markus Mottl
2001-09-03 16:31 ` Clement Renard
     [not found] ` <Pine.BSF.3.96.1010903120605.42306B-100000@fledge.watson.org>
2001-09-03 16:36   ` Markus Mottl
     [not found] ` <FLELJKKJEIKNBDJGMIHKGEFKCAAA.franka@cs.uu.nl>
2001-09-03 20:26   ` Markus Mottl
2001-09-04  6:20 ` Daniel de Rauglaudre
2001-09-04 12:43   ` Markus Mottl
2001-09-04 14:00     ` Daniel de Rauglaudre

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).