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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 29DAEBBAF for ; Tue, 27 Jul 2010 16:47:36 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AoACALuOTkyGnQCBlGdsb2JhbACDFI9YjHsVAQEBAQkLCAkRAx+wEJINgSaDHXMEhC8 X-IronPort-AV: E=Sophos;i="4.55,268,1278280800"; d="scan'208";a="56192520" Received: from shiva.jussieu.fr ([134.157.0.129]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 27 Jul 2010 16:47:35 +0200 Received: from hydrogene.pps.jussieu.fr (hydrogene.pps.jussieu.fr [134.157.168.1]) by shiva.jussieu.fr (8.14.4/jtpda-5.4) with ESMTP id o6RElYBI080776 ; Tue, 27 Jul 2010 16:47:35 +0200 (CEST) X-Ids:165 Received: from magnesium.localnet (balat@magnesium.pps.jussieu.fr [134.157.168.12]) by hydrogene.pps.jussieu.fr (8.13.4/jtpda-5.4) with ESMTP id o6RElXfc020844 ; Tue, 27 Jul 2010 16:47:33 +0200 From: Vincent Balat Organization: Laboratoire PPS - CNRS - =?utf-8?q?Universit=C3=A9_Paris?= Diderot To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] [Camlp4] Quotation expander with OCaml syntax Date: Tue, 27 Jul 2010 16:47:28 +0200 User-Agent: KMail/1.13.3 (Linux/2.6.32-2-amd64; KDE/4.4.4; x86_64; ; ) Cc: Thomas.Gazagnaire@sophia.inria.fr, "Raphael Proust" References: <54129.88.170.165.56.1280236965.squirrel@imap-sop.inria.fr> In-Reply-To: <54129.88.170.165.56.1280236965.squirrel@imap-sop.inria.fr> MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <201007271647.31062.vincent.balat@pps.jussieu.fr> X-Miltered: at jchkmail.jussieu.fr with ID 4C4EF186.00B by Joe's j-chkmail (http : // j-chkmail dot ensmp dot fr)! X-j-chkmail-Enveloppe: 4C4EF186.00B/134.157.168.1/hydrogene.pps.jussieu.fr/hydrogene.pps.jussieu.fr/ X-Spam: no; 0.00; camlp:01 expander:01 ocaml:01 syntax:01 syntax:01 camlp:01 branching:01 runtime:01 compiler:01 runtime:01 bigloo:01 compiler:01 www-sop:01 abstracted:01 node:01 > Are you trying to the same thing as HOP [1] ? No. Our precise goal and solutions are very different from Hop. Obviously w= e=20 share the main general idea (from the beginning 7 years ago -- and also wit= h=20 many other projects) which is to write both sides of Web applications with = the=20 same high level language. But that is not new (we have been doing this for= =20 years). Rapha=C3=ABl's work is to make easier to mix client and server code= in the=20 same file and simplify the interaction between the client and server. We=20 already have a syntax for this but it is not exactly the one we want (but t= his=20 is only a problem with camlp4). > What kind of restrictions do you impose on the expressions you can > transfer from the server to the client (only non-functional values) ? How > do you ensure them in your program ? >=20 > Are you sure splitting the code into two parts is sufficient ? How will > you handle branching than you can decide only at runtime, as example ? HOP > is using a javascrip compiler embedded in a library to compile efficiently > the right client code at runtime. >=20 > Btw, would be glad to have more details on what you have done and plan to > do as I am working on similar things (not very actively currently) : I've > been trying to make camloo, a caml-light to bigloo compiler, working > again (current version[2] is quite working - still few things to finish). > At one point, the goal would be to extand the source language with similar > constructs than yours and to compile to HOP ... You can find Eliom's documentation on http://ocsigen.org . The documentatio= n=20 for the development version is not yet written (we will put it online proba= bly=20 in september, and release version 2 of Eliom a few months later). If you ar= e=20 working on this with Manuel, we will probably meet soon during the next=20 meeting of the PWD project and I will explain you our solution in details. Vincent Balat > [1] http://hop.inria.fr > [2] http://www-sop.inria.fr/members/Thomas.Gazagnaire/ > -- > Thomas >=20 > > Hi all, > >=20 > > I'm working on a syntax extension as part of an internship in the >=20 > Ocsigen team. The aim of the syntax extension is to split the code of a > web >=20 > > application in two separate files: one for the client and one for the >=20 > server. A >=20 > > few transformations are to take place in the process. > >=20 > > Quotations are to be transformed into client code while antiquotations >=20 > can >=20 > > refer > > to server side values transmitted to the client at runtime. > >=20 > >=20 > > In order to avoid any XY problems, here is an abstracted and simplified >=20 > example >=20 > > of the expected behavior: > >=20 > > (* Pre-parsed code: *) > > let start =3D <:on< f $y$ >> in > > let html_node =3D > >=20 > > span ~a:[onclick start] "some text" (* a is used for (html) attributes >=20 > *) >=20 > > (* Server side post-parsed code: *) > > let start _arg1 =3D > >=20 > > "call_closure(some_unique_name," ^ mymarshall _arg1 ")" > >=20 > > in > > let html_node =3D span ~a:[onclick (start y)] "some text" > >=20 > > (* Client side post-parsed code: *) > > let _ =3D register_closure some_unique_name (fun _arg1 -> f _arg1) > >=20 > >=20 > >=20 > > If the example isn't clear enough I can detail it a little bit more. > >=20 > >=20 > > I'm unsure of what is the standard way of doing such a thing in Camlp4. >=20 > What >=20 > > I > > have in mind is to use the original Ocaml syntax for the quotation >=20 > expander. >=20 > > This would (IIUC) allow me to filter the AST to transform every > > antiquotation > > found inside the quotation itself. > >=20 > > I'm not sure this is the ideal way of doing such a thing because of the >=20 > size >=20 > > of > > the pattern matching in the AST filter. On the other hand, because the >=20 > quotation >=20 > > is supposed to contain valid OCaml code, it seems normal to reuse the >=20 > original >=20 > > parser. > >=20 > > I considered an alternative solution: treating quotations as raw text > > (with a > > custom quotation expander) but that would destroy any _loc information >=20 > and >=20 > > make > > compile time warnings and errors quite difficult to locate. > >=20 > >=20 > > Is there a simpler/fitter way of doing that? (Is the Y correct wrt the >=20 > X?) >=20 > > How can one embed the original parser in a quotation expander? (I >=20 > couldn't >=20 > > find > > a function of type string -> Ast.expr in the Camlp4 doc/mlis, but I'd be >=20 > happy >=20 > > to be pointed to one if it exists. I think it would at least require >=20 > some >=20 > > functor application.) > >=20 > > Does anyone know of any example that resemble what I'm trying to >=20 > achieve? >=20 > > -- > > _______ > > Raphael > > _______________________________________________ > > Caml-list mailing list. Subscription management: > > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > > Archives: http://caml.inria.fr > > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > > Bug reports: http://caml.inria.fr/bin/caml-bugs >=20 > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs