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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 3F59FBBAF for ; Fri, 17 Oct 2008 15:01:03 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AosEAPMo+EjAXQImiGdsb2JhbACTKz4CFiKkcn+HMgEDAQODaQ X-IronPort-AV: E=Sophos;i="4.33,431,1220220000"; d="scan'208";a="18218828" Received: from discorde.inria.fr ([192.93.2.38]) by mail3-smtp-sop.national.inria.fr with ESMTP; 17 Oct 2008 15:01:02 +0200 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id m9HD0wWK009592 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Fri, 17 Oct 2008 15:01:02 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AuEBAOQp+EhIDtyflGdsb2JhbACTKz4CAgkJDAcRA6Rvf4cuAQMBA4Np X-IronPort-AV: E=Sophos;i="4.33,431,1220220000"; d="scan'208";a="30457713" Received: from fg-out-1718.google.com ([72.14.220.159]) by mail4-smtp-sop.national.inria.fr with ESMTP; 17 Oct 2008 15:01:00 +0200 Received: by fg-out-1718.google.com with SMTP id e21so382478fga.25 for ; Fri, 17 Oct 2008 06:00:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=1XkjRnd/kQREjvyi28Skkn8SYAIMyL7L6oig9j0I4ac=; b=So2/EnIam3UsEqG169Ej9h9tTd03L8BdSIqwrl5Cpqu9KpUWL/X8vZuS0peyy1hu48 2mB7AhMS2yWqRoyLYT1YHItyco0Kj5Oiedadv24PJio1hFnvNMB3cQ4C8lrSyawcD61m 6EjPoVtwE+j3ifKITQONEIlNExoKLU0TsAszM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=DQEAx/utoeJokgHlK6yB2IUGaky6z2M4+OH/zfUik2IHI1XXxp2dXN1DhrhdrQ3n2z /zGlQ24m0vuUeM2MdwoyOl3Q51ZNKUFObedqf65Bp9v00ru897sHIqXbuoqFfZdhZRYk FElJNOpz2XRiRKlDXbr1g7PrH3OBoNyfYFTbA= Received: by 10.86.23.18 with SMTP id 18mr3909517fgw.6.1224248459376; Fri, 17 Oct 2008 06:00:59 -0700 (PDT) Received: by 10.86.2.19 with HTTP; Fri, 17 Oct 2008 06:00:59 -0700 (PDT) Message-ID: Date: Fri, 17 Oct 2008 14:00:59 +0100 From: "Conglun Yao" To: "Richard Jones" Subject: Re: [Caml-list] Camlp4 generate more than one (compiled) files? Cc: caml-list@inria.fr In-Reply-To: <20081017115257.GA21623@annexia.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20081017115257.GA21623@annexia.org> X-Miltered: at discorde with ID 48F88C8A.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; camlp:01 cmo:01 camlp:01 translated:01 cmo:01 syntax:01 syntax:01 ocaml:01 'ocaml:01 blog:98 wrote:01 wrote:01 caml-list:01 functions:01 functions:01 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 = "" 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 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 >