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 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id B874CBC0A for ; Wed, 18 Apr 2007 10:11:53 +0200 (CEST) Received: from nz-out-0506.google.com (nz-out-0506.google.com [64.233.162.228]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l3I8Bqdh010781 for ; Wed, 18 Apr 2007 10:11:53 +0200 Received: by nz-out-0506.google.com with SMTP id l8so69388nzf for ; Wed, 18 Apr 2007 01:11:52 -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=OrkxPxa/xs9PAFJ5+mjKnTWW7tiDgor5Iv+0sElCrMMmLu+1GhttMNOOZkv909o2qD5nE9/0JF7MW3qBU3yphuhG5p09hPQXTRkfTS22Y9eZlvjSlin6UKOQliaOY8hefCWvK8L4+y/hcMP9jw4z8ogzM5WiLwXGlGLcIjQ4344= 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=dh6g3mxRQC17WH6AlSoyg+43AbH/CdP82GK0mvswVwYssNbNR9YGSJ0nn7NbV2LIQzzC1cyA26qo4bg638VE9lwKqdhnwxqZnfS5M2Ik5OjfzmB92iFIXY0aa80elGeNIRygqD392pSpFEPxr3S3RrYhJUKU0r28XXJoQwq1Vpk= Received: by 10.114.52.1 with SMTP id z1mr87747waz.1176883912079; Wed, 18 Apr 2007 01:11:52 -0700 (PDT) Received: by 10.114.183.4 with HTTP; Wed, 18 Apr 2007 01:11:51 -0700 (PDT) Message-ID: Date: Wed, 18 Apr 2007 10:11:52 +0200 From: "Nicolas Pouillard" To: "Caml List" , "Aleksey Nogin" Subject: Re: [Caml-list] 3.10+beta: Camlp4: AST mapping treats record labels as patterns; should they have type ident instead? In-Reply-To: <462508EC.2090302@metaprl.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <462508EC.2090302@metaprl.org> X-j-chkmail-Score: MSGID : 4625D2C8.002 on concorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at concorde with ID 4625D2C8.002 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; camlp:01 camlp:01 defines:01 expr:01 expr:01 grammars:01 bindings:01 doable:01 node:01 arbitrary:01 wrote:01 workaround:01 caml-list:01 patt:01 patt:01 On 4/17/07, Aleksey Nogin wrote: > Currently Camlp4 AST defines the record patterns as > > PaRec of loc and list (patt * patt) > > and record expressions as > > ExRec of Loc.t and binding and expr Why do you mix the old definition of PaRec with the new definition of ExRec. I recall them: Before: | PaRec of loc and list (patt * patt) | ExRec of loc and list (patt * expr) and option expr Now: (* { p } *) | PaRec of Loc.t and patt (* { b } or { (e) with b } *) | ExRec of Loc.t and binding and expr To fully understand here is a fragment of pattern and binding grammars: patterns, p ::= ... | { p } | p1 = p2 | p1 ; p2 bindings, b ::= ... | p = e | b ; b > where the binding can bind arbitrary patterns to expressions. This was > not a big issue prior to 3.10, but now that 3.10 provides very powerful > mapping and folding features, this seems a bit problematic. Namely, if I > define a Camlp4 filter or an AST mapping function that affects patterns, > the array labels will get affected as well, often in an undesired way. It's undesired, but there is an easy workaround: .... method patt p = match p with | ... | <:patt@loc< $p1$ = $p2$ >> -> <:patt@loc< $p1$ = $super#patt p2$ >> | ... .... > Would it be better to have > PaRec of loc and list (ident * patt) > and > ExRec of loc and list (ident * expr) and expr > instead? There is no more lists in the camlp4 AST, that's a price to pay to have consistency w.r.t quotations. For patterns there is something doable: | PaEq of Loc.t and patt and patt (* p = p *) Can become | PaEq of Loc.t and ident and patt (* i = p *) Since that node is only used with an ident on his left. For expressions it's more complex, I won't do it. Regards, -- Nicolas Pouillard