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.1 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 2EAD9BC6B for ; Fri, 29 Jun 2007 16:06:42 +0200 (CEST) Received: from nz-out-0506.google.com (nz-out-0506.google.com [64.233.162.231]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l5TE6fkg031724 for ; Fri, 29 Jun 2007 16:06:41 +0200 Received: by nz-out-0506.google.com with SMTP id z3so424565nzf for ; Fri, 29 Jun 2007 07:06:40 -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:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=PBAPFMLj258KZvhqGR17AwTyQ+K7KBtf0sdMF6TKBbly69CApRr1nLyQiKTzFp2OvpARqBEYUoeKrGLPHHFkGLbS8WPFchGsIUZGTqTNX+kHQQJsm0/bPpxxOhMXIg4Ng81VEuof5iyBPyNvl0dm8eDInxi1uspeWNYtY7dN0I4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=uPCGla9RtxYjjBVMkJehXiNDcUhb0oaIvZ7SLN9nDB0p7DQrJHKIXnvhotGLST/TC/wsmvieNF4nj6QBL74fDY6WvyE8/uTkrJfNtpaJ/NKmG1/ZU2hSYwgWO1//Wt3Odj1F0d+b8cVqq3qHz6llAD4mcU3dLv6b0Mvhh1XmPVA= Received: by 10.114.36.1 with SMTP id j1mr2649434waj.1183126000216; Fri, 29 Jun 2007 07:06:40 -0700 (PDT) Received: by 10.114.181.8 with HTTP; Fri, 29 Jun 2007 07:06:40 -0700 (PDT) Message-ID: Date: Fri, 29 Jun 2007 16:06:40 +0200 From: "Nicolas Pouillard" To: "Benedikt Grundmann" Subject: Re: [Caml-list] camlp4 -I and shared libs Cc: "Robert Roessler" , Caml-list In-Reply-To: <9b415f950706290344g691b3b6emf7316944289b113e@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <4684DDB2.3000007@rftp.com> <9b415f950706290344g691b3b6emf7316944289b113e@mail.gmail.com> X-j-chkmail-Score: MSGID : 468511F1.000 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 468511F1.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; camlp:01 libs:01 grundmann:01 wiki:01 camlp:01 ocaml:01 wiki:01 syntax:01 foo:01 failwith:01 expr:01 expr:01 failwith:01 ocamlc:01 -pp:01 On 6/29/07, Benedikt Grundmann wrote: > Hi everybody, > > At the risk of sounding harsh, I do not like this wiki at all, due to > several reasons: > > 1) Default style sheet is a partial user interface nightmare, a lot of > the links are embedded in titles, which happen to have nearly the > same styling... So you actually have to hover above each title to find > the links. You're right. > 2) Structure is a mess... Camlp4 can do a lot and that is great. But > I do believe that the primary motivation is the extension of OCaml and > some simple examples, or even better yet some kind of tutorial is > needed. It definitely should start simple maybe even over simplifying > things and very very gradually introduce the true power... Yes but, for now I was more concentrated on explaining differences and improvements, and that's about advanced features. [...] > PS: I do not want to start a flame war, or offend the creators of the > Wiki. I just wanted to point out that right now the wiki is not > helpful, unless you already now a lot about camlp4... That's a good point, that I am aware of. > PPS: My syntax extension captures the identifier msg. How is one > supposed to write hygienic macros? Should I just store a counter > somewhere and generate identifiers like "msg__32432" and hope that > nobody else uses the same prefix, or is there some support for things > like that in camlp4? You can start by checking that the user don't use that variable. Using the generated fold it's easy. $ cat foo.ml open Camlp4.PreCast;; let filter = object (o) inherit Ast.fold as super (* capture most of cases *) method ident i = let o = super#ident i in match i with | <:ident< msg >> -> failwith "msg forbidden" | _ -> o (* there is perhaps some more... *) method expr e = let o = super#expr e in match e with | <:expr< for msg = $_$ $to:_$ $_$ do $_$ done >> -> failwith "msg forbidden" | _ -> o end;; AstFilters.register_str_item_filter (fun st -> let _ = filter#str_item st in st) $ ocamlc -c -I +camlp4 -pp camlp4of foo.ml $ cat bar.ml let msg = 42 $ camlp4o ./foo.cmo bar.ml -- Nicolas Pouillard