From: "Conglun Yao" <yaoconglun@gmail.com>
To: "Richard Jones" <rich@annexia.org>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Camlp4 generate more than one (compiled) files?
Date: Fri, 17 Oct 2008 14:00:59 +0100 [thread overview]
Message-ID: <f7b50d2a0810170600p501fe894q9e5f4b10f54ef11b@mail.gmail.com> (raw)
In-Reply-To: <20081017115257.GA21623@annexia.org>
Rich,
Thanks for your reply.
What you mentioned in your blog:
In fact saving the AST into the cmo file is relatively simple: we just
turn it into a string (using Marshal) and write out the string as a
camlp4 substitution:
let bitmatch ext2sb = { ... }
becomes: let ext2sb = "<string containing marshalled representation of AST>"
If I understand correctly, the translated ext2sb would be kept in the
same cmo file(where the ext2sb is defined in the extended syntax),
rather than an additional (new) cmo file.
Currently I'm facing the problem that write a single file in extended
syntax, then camlp4 it into two different cmo files.
e.g. in extendFile.ml, we define a type t
type myextend t = * type definition in my extended syntax *
then I want to translate it into:
extendFile.cmo:
type t = * standard ocaml type definition *
module T and some t-related functions
and another file newFile.cmo :
some functions which doesn't rely on type t,
like checking the existence of some files (name mentioned in type
t's definition)
I know it's possible to generate the latter functions and pretty-print
them into newFile.ml, but don't know how to get a compiled cmo file
directly.
Conglun
Conglun
On Fri, Oct 17, 2008 at 12:52 PM, Richard Jones <rich@annexia.org> wrote:
> 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
>
prev parent reply other threads:[~2008-10-17 13:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-17 11:15 Conglun Yao
2008-10-17 11:52 ` [Caml-list] " Richard Jones
2008-10-17 13:00 ` Conglun Yao [this message]
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=f7b50d2a0810170600p501fe894q9e5f4b10f54ef11b@mail.gmail.com \
--to=yaoconglun@gmail.com \
--cc=caml-list@inria.fr \
--cc=rich@annexia.org \
/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