From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id CF6C1BBAF for ; Wed, 7 Apr 2010 22:24:14 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AmcBAEaGvEtCbwQakWdsb2JhbACDE5gQFQEBAQEJCwoHEQQeqz2QUgWBLIJvboMo X-IronPort-AV: E=Sophos;i="4.52,164,1270418400"; d="scan'208";a="56662950" Received: from out2.smtp.messagingengine.com ([66.111.4.26]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/ADH-AES256-SHA; 07 Apr 2010 22:24:14 +0200 Received: from compute2.internal (compute2.internal [10.202.2.42]) by gateway1.messagingengine.com (Postfix) with ESMTP id 3FBE3EAB21; Wed, 7 Apr 2010 16:24:13 -0400 (EDT) Received: from heartbeat2.messagingengine.com ([10.202.2.161]) by compute2.internal (MEProxy); Wed, 07 Apr 2010 16:24:13 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=messagingengine.com; h=message-id:date:from:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding; s=smtpout; bh=BbMp/r6jFOtrZ7TKoa00po7K5jM=; b=o5jFqXZNifeAfVea8/1zU0AE8wtNB4yDTbZ+fANnw49G32rvqgSsZ72k5OcDV0qz653L4l99YsHe3nXOpCUDrX61zMWfcHXhVEa4PzgKfV+wLuzXiSaHd9G75tOmGGSBRHBOE8lr//D+ecYXx1NPcBnHoYNNG1JQSQ+fwO45Yww= X-Sasl-enc: AbKUM8xut2kyGaNqaEL1bmpoKh12rLupY7A6SSAmXM0m 1270671852 Received: from [192.168.1.61] (64-71-1-162.static.wiline.com [64.71.1.162]) by mail.messagingengine.com (Postfix) with ESMTPSA id 9C84ADECF; Wed, 7 Apr 2010 16:24:12 -0400 (EDT) Message-ID: <4BBCE9EB.6020704@ens-lyon.org> Date: Wed, 07 Apr 2010 13:24:11 -0700 From: Martin Jambon User-Agent: Thunderbird 2.0.0.22 (X11/20090908) MIME-Version: 1.0 To: =?UTF-8?B?SsOpcsOpbWllIERpbWlubw==?= Cc: Jacques Le Normand , caml-list caml-list Subject: Re: [Caml-list] camlp4 infix let References: <1270669515.22777.4.camel@aurora> In-Reply-To: <1270669515.22777.4.camel@aurora> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam: no; 0.00; ens-lyon:01 camlp:01 infix:01 camlp:01 syntax:01 expr:01 expr:01 syntax:01 backslash:01 foo:01 cmo:01 foo:01 ocaml:01 wrote:01 rec:01 Jérémie Dimino wrote: > Hi, > > Le mercredi 07 avril 2010 à 15:05 -0400, Jacques Le Normand a écrit : >> Dear List, >> I'm writing a camlp4 syntax extension and I'd like to write >> >> <:expr< let ( >>= ) = Bar.( >>= ) in 5 >> >> but camlp4 complains: >> >> While expanding quotation "expr" in a position of "expr": >> Parse error: ")" or [ipatt] expected after "(" (in [ipatt]) >> >> yet it seems to be valid revised syntax. Does anyone have any ideas? The revised syntax of the old camlp4 or camlp5 requires a backslash in front of the operator instead of parentheses: $ cat foo.ml let \>>= = Bar.\>>= in 5 ; $ camlp5r pr_o.cmo foo.ml let _ = let (>>=) = Bar.(>>=) in 5 I don't know how to make it work with the new camlp4: $ camlp4r -printer o foo.ml File "foo.ml", line 1, characters 4-8: Parse error: "module" or [opt_rec] expected after "let" (in [expr]) > It is because the ">>" of the ">>=" operator is detected as the end of > the camlp4 quotation. You can try something like that: > > let operator = ">>=" in <:expr< let ($lid:operator$) = Bar.($lid:operator$) in 5 >> I would add it is simpler to just avoid << and >> in any ocaml source code unless camlp5/camlp4 is not involved. Martin -- http://mjambon.com/