From: "Loup Vaillant" <loup.vaillant@gmail.com>
To: "Caml List" <caml-list@inria.fr>
Subject: Re: [Caml-list] C-like macros in OCaml
Date: Thu, 28 Jun 2007 09:38:47 +0200 [thread overview]
Message-ID: <6f9f8f4a0706280038id129a00qd363e19de73a973e@mail.gmail.com> (raw)
In-Reply-To: <6f9f8f4a0706280037h5f19af5flb764e1c2999b0337@mail.gmail.com>
2007/6/27, Christopher L Conway <cconway@cs.nyu.edu>:
> On 6/27/07, Loup Vaillant <loup.vaillant@gmail.com> wrote:
> > By the way, does camlp4 handle cross modules C-like macros? If it does, how?
> > For instance, what if I write, in foo.ml :
> > [...]
> > Will I get what I want?
>
> Probably not, but that depends on what you want. ;-) I believe that
> pa_macro DEFINEs have module scope.
Too bad. Actually, I want to implement a Lisp syntax for Ocaml, which
means I also want Lisp macros (regular and reader ones). Lisp macros
are often used extensively (Paul Graham talks about over 20% of the
code). That is why I want properly scoped macros : no global
namespace, and yet the possibility to use them between compilation
unit.
The only solution I came up with was producing at parsing type some
file for each .ml file containing a macro, so the preprocessor can
check these when parsing another file using this macro.
Hence my question : doesn't camlp4 provide a better solution to this
kind of problem? I know very little about the inner core of camlp4,
but I am sure I can reuse some ideas.
> To get the same DEFINE in multiple
> files, you can use -D arguments on the command line, but pa_macro
> doesn't allow these arguments to have values (i.e., you can only test
> IFDEF/IFNDEF).* If you want arguments, see pa_macro_arg:
> http://caml.inria.fr/cgi-bin/hump.en.cgi?contrib=569
I will take a look, thanks for the pointer.
Loup
next prev parent reply other threads:[~2007-06-28 7:38 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-26 22:00 Raj B
2007-06-26 22:06 ` [Caml-list] " Jonathan Bryant
2007-06-27 4:10 ` Richard Jones
2007-06-27 7:43 ` Jeremy Yallop
2007-06-27 8:08 ` Loup Vaillant
2007-06-27 12:53 ` Christopher L Conway
[not found] ` <6f9f8f4a0706280037h5f19af5flb764e1c2999b0337@mail.gmail.com>
2007-06-28 7:38 ` Loup Vaillant [this message]
2007-06-28 7:44 ` Nicolas Pouillard
[not found] <20070627044609.6B456BC77@yquem.inria.fr>
2007-06-27 7:21 ` David Allsopp
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=6f9f8f4a0706280038id129a00qd363e19de73a973e@mail.gmail.com \
--to=loup.vaillant@gmail.com \
--cc=caml-list@inria.fr \
/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