caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Joseph Young <ocaml@optimojoe.com>
To: Andy Ray <evilkidder@googlemail.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] camlp4
Date: Sun, 7 Feb 2010 14:51:09 +0100 (CET)	[thread overview]
Message-ID: <Pine.LNX.4.64.1002071417180.5672@myhome> (raw)
In-Reply-To: <b69aa6441002051716i145c4eb5wadb72f9bf908c460@mail.gmail.com>

On Sat, 6 Feb 2010, Andy Ray wrote:

> Hi,
>
> My project would really benefit from some simple camlp4 syntax
> extensions, however, I am put off by the lack of a reference manual
> for it.
>
> At the moment I am tempted to go for camlp5 instead - not least
> because I was able to work through it's manual and get some examples
> working a while back.
>
> The reality is I would prefer to use camlp4 as it appears to the
> official ocaml supported way, but can't see how to get into it as a
> beginner due to the lack of documentation (and that appears to have
> been the case for quite some time now).  What should one do?
>
> Cheers,
> Andy
>
> _______________________________________________
> 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
>

 	Though slightly tangental, I use both camlp4 and camlp5 for the 
quotation system.  As already mentioned, the lack of documentation is a 
problem, but it is not insurmountable.  At this point, I prefer camlp4 to 
camlp5 for the following reasons.  First, I like how locations are handled 
in camlp4 as opposed to camlp5.  In camlp4, a function registered as a 
quotation accepts a string, a location, and optional location arguments. 
In camlp5, the function accepts only a string and the location information 
is passed in indirectly.  I find this direct handling of locations easier 
to manipulate.  Second, camlp4 allows me to register a quotation for a 
specific kind of ocaml ast (expression, pattern, whatever.)  In camlp5, 
every time I register a quotation, I must supply code for both expressions 
and patterns.  Third, although initially extremely confusing, I now prefer 
the functor organization that camlp4 uses.  The functors make it clear as 
to how the syntax is extended.  For example, the the original OCaml syntax 
is represented as an extension of the revised syntax.  In order to create 
the appropriate original syntax module in camlp4, we use the code:

module CamlSyntax=Camlp4OCamlParser.Make(
 	Camlp4OCamlRevisedParser.Make(
 		Camlp4.PreCast.Syntax));;

Here, we can see that PreCast adds the necessary starting material, the 
revised parser adds the revised syntax, and the original syntax is an 
extension of the revised.  Because of this organization, I find the 
relationship of syntax extensions more clear in camlp4.  In order to make 
this organization more understandable, make sure you use ocamlbrowser and 
not the module M=Stuff trick on the top level.  The nesting of modules in 
camlp4 is huge.

 	In any case, both work extremely well and much of what you should 
use comes down to preference.


  parent reply	other threads:[~2010-02-07 14:13 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-06  1:16 camlp4 Andy Ray
2010-02-06 11:15 ` [Caml-list] camlp4 blue storm
2010-02-06 12:14 ` Tiphaine Turpin
2010-02-06 12:44   ` Guillaume Yziquel
2010-02-09 15:30     ` Guillaume Yziquel
2010-02-09 18:29       ` Jake Donham
2010-02-07 17:19   ` Martin DeMello
2010-02-08  1:14     ` Ashish Agarwal
2010-02-08  2:01       ` Yoann Padioleau
2010-02-08  2:03       ` Erik de Castro Lopo
2010-02-06 13:37 ` Ed Keith
2010-02-06 16:25   ` camlp4 Chris Conway
2010-02-07 13:51 ` Joseph Young [this message]
  -- strict thread matches above, loose matches on Subject: below --
2008-01-18 17:08 camlp4 Christian Sternagel
2008-01-18 18:56 ` [Caml-list] camlp4 Nicolas Pouillard
2008-01-18 19:30 ` Olivier Andrieu
2008-01-18 19:53   ` Nicolas Pouillard
2008-01-19 15:09     ` Christian Sternagel
2008-01-20 15:23       ` Nicolas Pouillard
2008-01-22 13:33         ` Christian Sternagel
2008-01-22 13:42           ` Nicolas Pouillard
2008-01-22 14:06             ` Loup Vaillant
2008-01-22 14:26               ` Nicolas Pouillard
2008-01-22 16:43             ` Christian Sternagel
2008-01-22 18:20               ` Nicolas Pouillard
2008-01-24  9:01                 ` Christian Sternagel
2004-01-04 16:49 [Caml-list] novice puzzled by speed tests Xavier Leroy
2004-01-05 19:50 ` [Caml-list] camlp4 Ker Lutyn
2003-07-08 12:49 [Caml-list] -unsafe and camlp4 "Dmitry Bely" 
2003-07-08 13:38 ` Xavier Leroy
2003-07-08 15:38   ` [Caml-list] camlp4 Dmitry Bely
2003-07-22 11:14     ` Damien Doligez
2003-06-10 14:22 Pierre CHATEL
2003-02-07 11:11 [Caml-list] Camlp4 Daniel de Rauglaudre
2003-02-08  0:26 ` Issac Trotts
2003-02-08 17:23 ` Geoff Wozniak
2002-05-17 13:19 Ohad Rodeh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.64.1002071417180.5672@myhome \
    --to=ocaml@optimojoe.com \
    --cc=caml-list@inria.fr \
    --cc=evilkidder@googlemail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).