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=1.0 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 5CE78BC6B for ; Thu, 28 Jun 2007 09:38:48 +0200 (CEST) Received: from an-out-0708.google.com (an-out-0708.google.com [209.85.132.246]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l5S7cl6a008934 for ; Thu, 28 Jun 2007 09:38:48 +0200 Received: by an-out-0708.google.com with SMTP id c24so96925ana for ; Thu, 28 Jun 2007 00:38:47 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=KTJfY8HAE5mdho5n/hPfPgvibLlZ/lvp4T0c2OhGo7CF6CSbbb1bGlKC8FtXJwwtA6p9nbg4//mTEDGJGU0PfF/bxDee6yXvDl0735m+UjnMTxVncXo3le9+Lqzl2YXMqTlgfsvGJmCqJsQCP1E8Z8ITn/IvsDXSi8J9DhqtxSE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=ZnGv/TFJB311ZPgfJgTsvp+M2mjE3a6ag7dQCWxZ+Oyyx7xxJsXCAMFqqvaAU8f9rVgbe+YTtPsLWye4EVdRYX8ui/BUxrtMp1K2KxsqGGJCfDpZpgaK5wAbsFlGG9GCk/t9Q5UkqXfn+mCWwjb37xP3ypGfPDVYcs5wyUCLubo= Received: by 10.100.12.18 with SMTP id 18mr990990anl.1183016327133; Thu, 28 Jun 2007 00:38:47 -0700 (PDT) Received: by 10.100.33.15 with HTTP; Thu, 28 Jun 2007 00:38:47 -0700 (PDT) Message-ID: <6f9f8f4a0706280038id129a00qd363e19de73a973e@mail.gmail.com> Date: Thu, 28 Jun 2007 09:38:47 +0200 From: "Loup Vaillant" To: "Caml List" Subject: Re: [Caml-list] C-like macros in OCaml In-Reply-To: <6f9f8f4a0706280037h5f19af5flb764e1c2999b0337@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <1B4EC64C-435D-42C5-95F3-C01869DD41FB@rice.edu> <20070627041034.GA7232@furbychan.cocan.org> <46821522.80602@ed.ac.uk> <6f9f8f4a0706270108i10eeef7eme5c1a397158d85c4@mail.gmail.com> <4a051d930706270553o2227f1e2h54893fd0929855dc@mail.gmail.com> <6f9f8f4a0706280037h5f19af5flb764e1c2999b0337@mail.gmail.com> X-j-chkmail-Score: MSGID : 46836587.003 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 46836587.003 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; c-like:01 ocaml:01 camlp:01 c-like:01 foo:01 defines:01 syntax:01 ocaml:01 extensively:01 compilation:01 camlp:01 ifdef:01 contrib:01 pointer:01 parsing:01 2007/6/27, Christopher L Conway : > On 6/27/07, Loup Vaillant 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