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.6 required=5.0 tests=AWL,DNS_FROM_RFC_POST, 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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 77C56BBAF for ; Sat, 24 Jan 2009 21:34:58 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApoBAH8Ke0lKfU4Yjmdsb2JhbACTPT8BAQEBCQsICQ8FpSuBBY4tAQMBA4VJ X-IronPort-AV: E=Sophos;i="4.37,318,1231110000"; d="scan'208";a="20113974" Received: from ey-out-2122.google.com ([74.125.78.24]) by mail2-smtp-roc.national.inria.fr with ESMTP; 24 Jan 2009 21:34:58 +0100 Received: by ey-out-2122.google.com with SMTP id d26so720517eyd.15 for ; Sat, 24 Jan 2009 12:34:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=vuvFdNCWVC2CFpThVwQF4JDAXI/cpUP+9w+M/2vNAX4=; b=Ok2YooZyIiuL7Wu+sHeD3NOwWIN3drqUawPLsf2+JjqTkvhugPaCZgmR2wA+85Pvod jI4G4D2Jyco84YoAhtmtnbMwKGkcaYwME8nE9oN8lAI1u91prSpkgmCfJZc6vdBJdW8U KG54NL7socp6CyAQqnXx/L6ntd8h4Ekzv2Ouo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=dOJHiN96oBcWJ3RQverra1s95DOc/Db1ybhouBohWEnfWSR6m/BpcirsaRe0lbccxZ cWU3E7zzGLZNIA6kHzBC1+paW5pB4l7lzyCr+YIlh12IUK7vIoKNpFb/QTWso3aJxQaA y1oe5ekS9LEXlawzsR6q4EargWWFSaLADG+hQ= MIME-Version: 1.0 Received: by 10.210.28.4 with SMTP id b4mr3915542ebb.120.1232829297083; Sat, 24 Jan 2009 12:34:57 -0800 (PST) In-Reply-To: References: Date: Sat, 24 Jan 2009 21:34:57 +0100 Message-ID: <527cf6bc0901241234j6feb859en643fd33049a8f63b@mail.gmail.com> Subject: Re: [Caml-list] camlp4 compilation model From: blue storm To: =?ISO-8859-1?Q?Mikkel_Fahn=F8e_J=F8rgensen?= Cc: "O'Caml Mailing List" Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam: no; 0.00; camlp:01 compilation:01 model:01 mikkel:01 rgensen:01 mikkel:01 ocaml:01 camlp:01 ocaml:01 syntax:01 compiler:01 modular:01 constructors:01 syntax:01 mikelin:01 On 1/24/09, Mikkel Fahn=F8e J=F8rgensen wrote: > a) I understand you can write a cryptic ocaml program that effectively > builds and AST from whatever grammar you decide by applying camlp4. Right. > b) I also understand that camlp4 it has a built in ocaml syntax that > you can extend, and therefore use as camlp4 as a prepreprocessor to > the ocaml compiler as part of the build process. Right. It is actually a bit more modular than that : Camlp4 has built-in Ocaml AST and quotations (~ syntaxic sugar for AST constructors in expressions or patterns), and provide a way to extend any camlp4-defined syntax. OCaml compilers can integrate preprocessors (not only camlp4, see eg. http://people.csail.mit.edu/mikelin/ocaml+twt/ ) as a part of the build process. > It seems that an enduser program can link with a camlp4 enhanced > library and magically have its syntax extended without adding camlp4 > to the build process (once the library has been built). For example > the bitstring library introduces the bitmatch syntax. > > Is this correct understood, and how does that work? I do not think it is correct. IIRC, bitstring needs (when using the syntaxic extension) camlp4 in the user build process. Richard Jones may correct me on this though. > One reason I put camlp4 on hold was precisely that added compilation > complexity, but if it can be hidden in a library, it is an entirely > different situation. I do not know of any way of "hiding" the preprocessing phase. That said, the build process does not have to be painful. You can use ocamlfind ( http://projects.camlcity.org/projects/dl/findlib-1.2.1/doc/guid= e-html/x412.html ), or ocamlbuild, to integrate syntax extensions more easily.