From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 09E31BBAF for ; Fri, 17 Oct 2008 13:52:59 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AokEAAMZ+EjAXQIniGdsb2JhbACTaQIWIq1Kg2w X-IronPort-AV: E=Sophos;i="4.33,431,1220220000"; d="scan'208";a="18861799" Received: from concorde.inria.fr ([192.93.2.39]) by mail1-smtp-roc.national.inria.fr with ESMTP; 17 Oct 2008 13:52:58 +0200 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id m9HBqwud027451 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Fri, 17 Oct 2008 13:52:58 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AokEAH8Z+EhQRFuwiGdsb2JhbACTaQIWIq1Ug2w X-IronPort-AV: E=Sophos;i="4.33,431,1220220000"; d="scan'208";a="16197500" Received: from furbychan.cocan.org ([80.68.91.176]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES256-SHA; 17 Oct 2008 13:52:58 +0200 Received: from rich by furbychan.cocan.org with local (Exim 4.63) (envelope-from ) id 1Kqnt3-0005gQ-Ed; Fri, 17 Oct 2008 12:52:57 +0100 Date: Fri, 17 Oct 2008 12:52:57 +0100 To: Conglun Yao Cc: caml-list@inria.fr Subject: Re: [Caml-list] Camlp4 generate more than one (compiled) files? Message-ID: <20081017115257.GA21623@annexia.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.13 (2006-08-11) From: Richard Jones X-Miltered: at concorde with ID 48F87C9A.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; camlp:01 0100,:01 camlp:01 compiler:01 cmo:01 syntax:01 preprocess:01 cmo:01 'ocaml:01 wrote:01 wrote:01 caml-list:01 module:03 library:03 compiled:04 On Fri, Oct 17, 2008 at 12:15:08PM +0100, Conglun Yao wrote: > I'm just wondering is it possible to use camlp4 to generate more than > one compiled files. > Normally, camlp4 preprocesses a file and then pass it directly to > compiler (for *.cmo), or its pretty-printer (for *.ml or other > 'plain' file). > > In my case, I want to extend the syntax, and write a file, then > preprocess (camlp4) it to generate two different *.cmo files, each one > could be executed separately. > > Is it possible? 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