caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Nicolas Pouillard" <nicolas.pouillard@gmail.com>
To: "Benedikt Grundmann" <benedikt@cardexpert.net>
Cc: "Robert Roessler" <roessler@rftp.com>, Caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] camlp4 -I and shared libs
Date: Fri, 29 Jun 2007 16:06:40 +0200	[thread overview]
Message-ID: <cd67f63a0706290706x4d7a32cdi22316694814d37e5@mail.gmail.com> (raw)
In-Reply-To: <9b415f950706290344g691b3b6emf7316944289b113e@mail.gmail.com>

On 6/29/07, Benedikt Grundmann <benedikt@cardexpert.net> wrote:
> Hi everybody,
>
> At the risk of sounding harsh, I do not like this wiki at all, due to
> several reasons:
>
> 1) Default style sheet is a partial user interface nightmare, a lot of
> the links are embedded in  titles, which happen to have nearly the
> same styling... So you actually have to hover above each title to find
> the links.

You're right.

> 2) Structure is a mess...  Camlp4 can do a lot and that is great.  But
> I do believe that the primary motivation is the extension of OCaml and
> some simple examples, or even better yet some kind of tutorial is
> needed. It definitely should start simple maybe even over simplifying
> things and very very gradually introduce the true power...

Yes but, for now I was more concentrated on explaining differences and
improvements, and that's about advanced features.

[...]

> PS: I do not want to start a flame war, or offend the creators of the
> Wiki.  I just wanted to point out that right now the wiki is not
> helpful, unless you already now a lot about camlp4...

That's a good point, that I am aware of.

> PPS: My syntax extension captures the identifier msg.  How is one
> supposed to write hygienic macros?  Should I just store a counter
> somewhere and generate identifiers like "msg__32432" and hope that
> nobody else uses the same prefix, or is there some support for things
> like that in camlp4?

You can start by checking that the user don't use that variable.

Using the generated fold it's easy.

$ cat foo.ml
open Camlp4.PreCast;;
let filter = object (o) inherit Ast.fold as super

  (* capture most of cases *)
  method ident i =
     let o = super#ident i in
     match i with
     | <:ident< msg >> -> failwith "msg forbidden"
     | _ -> o

  (* there is perhaps some more... *)
  method expr e =
     let o = super#expr e in
     match e with
     | <:expr< for msg = $_$ $to:_$ $_$ do $_$ done >> -> failwith
"msg forbidden"
     | _ -> o
end;;
AstFilters.register_str_item_filter (fun st -> let _ = filter#str_item st in st)

$ ocamlc -c -I +camlp4 -pp camlp4of foo.ml

$ cat bar.ml
let msg = 42

$ camlp4o ./foo.cmo bar.ml

-- 
Nicolas Pouillard


  reply	other threads:[~2007-06-29 14:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-25  3:33 Jake Donham
2007-06-25 12:57 ` [Caml-list] " Martin Jambon
2007-06-25 14:19   ` Nicolas Pouillard
2007-06-25 18:24     ` Jake Donham
2007-06-27  5:32       ` Jake Donham
2007-06-29  7:49     ` Hendrik Tews
2007-06-29  9:39       ` Nicolas Pouillard
2007-06-29 10:23         ` Robert Roessler
2007-06-29 10:44           ` Benedikt Grundmann
2007-06-29 14:06             ` Nicolas Pouillard [this message]
2007-06-29 12:41         ` skaller
2007-06-29 13:48           ` Nicolas Pouillard

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=cd67f63a0706290706x4d7a32cdi22316694814d37e5@mail.gmail.com \
    --to=nicolas.pouillard@gmail.com \
    --cc=benedikt@cardexpert.net \
    --cc=caml-list@inria.fr \
    --cc=roessler@rftp.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).