From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 14FEEBC2F for ; Wed, 1 Dec 2004 12:43:48 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id iB1BhlZD026251 for ; Wed, 1 Dec 2004 12:43:47 +0100 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id MAA23093 for ; Wed, 1 Dec 2004 12:43:47 +0100 (MET) Received: from quincy.inria.fr (quincy.inria.fr [128.93.8.52]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id iB1Bhdh8026237; Wed, 1 Dec 2004 12:43:40 +0100 Received: by quincy.inria.fr (Postfix, from userid 23861) id BD88811CE63; Wed, 1 Dec 2004 12:43:39 +0100 (CET) Date: Wed, 1 Dec 2004 12:43:39 +0100 From: Michel Mauny To: Arturo Borquez Cc: caml-list@inria.fr Subject: Re: [Caml-list] infix operator for the revised syntax Message-ID: <20041201114339.GG4582@quincy.inria.fr> Reply-To: Michel.Mauny@inria.fr References: <29C8881F.307FAC54.00958B05@netscape.net> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <29C8881F.307FAC54.00958B05@netscape.net> User-Agent: Mutt/1.4.1i X-Miltered: at concorde with ID 41ADAE73.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 41ADAE6B.002 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; mauny:01 mauny:01 caml-list:01 infix:01 syntax:01 wrote:01 ecrivait:01 camlers:01 syntax:01 explicitely:01 ocaml:01 ocaml:01 htmlman:01 bug:01 syntaxes:01 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.0 X-Spam-Level: Hello, Arturo Borquez wrote/écrivait (Tue, Nov 30, 2004 at 01:50:55PM -0500): > Dear Camlers, > > I've failed do do a syntax extention to the > revised syntax > [...] > let ( $ ) f g = g (f);; (* provided by normal syntax works fine *) Please note that using `$' as an operator is explicitely discouraged in the OCaml manual: http://caml.inria.fr/ocaml/htmlman/manual009.html Furthermore, there is a bug in Camlp4 3.08.2 that prevents using `$' as anything else than the antiquotation delimiter in the Camlp4-preprocessed syntaxes. This is fixed in the CVS (see http://caml.inria.fr/bin/caml-bugs/fixed?id=3310 foran explanation and a patch). > [...] in order to get a *real* infix operator for function > concatenation in order to avoid excessive parenthesis. > example with lists (silly) > > let ( $ ) f g = g (f);; (* provided by normal syntax works fine *) > let r = List.map ... a_list $ List.sort ... $ List.fold_left ... in .. > (* that's i whant to write with the revised syntax *) > > let r = List_fold_left ... ((List.sort ...) List.map ... a_list) in .. As far as I understand, what you want is to extend the revised syntax with a new construct/operator. The Camlp4 documentation is your friend here (http://caml.inria.fr/camlp4/manual/manual006.html#toc16, http://caml.inria.fr/camlp4/tutorial/tutorial007.html#toc49, etc.). For instance (using the revised syntax), the following could help you. (Change AFTER ":=" with the precedence level you want.) open Pcaml; (* Reversed application *) value send_to x f = f x; EXTEND expr: AFTER ":=" [[ e1 = expr; "sentto"; e2 = expr -> <:expr< send_to $e1$ $e2$ >> ]]; END; Hope this helps, -- Michel Mauny