From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id AD8BE7FA5E for ; Fri, 21 Apr 2017 19:11:42 +0200 (CEST) Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=alain.frisch@lexifi.com; spf=None smtp.mailfrom=alain.frisch@lexifi.com; spf=None smtp.helo=postmaster@vrout10.yaziba.net Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of alain.frisch@lexifi.com) identity=pra; client-ip=185.56.204.32; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="alain.frisch@lexifi.com"; x-sender="alain.frisch@lexifi.com"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of alain.frisch@lexifi.com) identity=mailfrom; client-ip=185.56.204.32; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="alain.frisch@lexifi.com"; x-sender="alain.frisch@lexifi.com"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@vrout10.yaziba.net) identity=helo; client-ip=185.56.204.32; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="alain.frisch@lexifi.com"; x-sender="postmaster@vrout10.yaziba.net"; x-conformance=sidf_compatible IronPort-PHdr: =?us-ascii?q?9a23=3A1GtGfhGTwGA1F+UV2aloJp1GYnF86YWxBRYc798d?= =?us-ascii?q?s5kLTJ7zrsqwAkXT6L1XgUPTWs2DsrQf2raQ6/iocFdDyK7JiGoFfp1IWk1Nou?= =?us-ascii?q?QttCtkPvS4D1bmJuXhdS0wEZcKflZk+3amLRodQ56mNBXdrXKo8DEdBAj0OxZr?= =?us-ascii?q?KeTpAI7SiNm82/yv95HJbQhFgDWwbaluIBmqsA7cqtQYjYx+J6gr1xDHuGFIe+?= =?us-ascii?q?NYxWNpIVKcgRPx7dqu8ZBg7ipdpesv+9ZPXqvmcas4S6dYDCk9PGAu+MLrrxjD?= =?us-ascii?q?QhCR6XYaT24bjwBHAwnB7BH9Q5fxri73vfdz1SWGIcH7S60/VC+85Kl3VhDnlC?= =?us-ascii?q?YHNyY48G7JjMxwkLlbqw+lqxBm3oLYfJ2ZOP94c6jAf90VWHBBU95MWSJfDIOy?= =?us-ascii?q?b4gBAeQPMulXrYbyu1QAoACiBQSuHu7j1iNEi3H00KA8zu8vERvG3AslH98WrH?= =?us-ascii?q?nUqM/6NKYUUeuozKfI1zTDb+hK1jf99YPFdQouofWWUrJxd8rd00cvFxnEjlWL?= =?us-ascii?q?tYPlPyiY1uATvGmU7upgW+Ovh3Q7pAF2pzii38EhgZTHiIISz1DL7yR5wIAtKN?= =?us-ascii?q?23SU57fd6kEIZLuC2AK4R2RcYiTmd1syg50r0LoYO3cSsKxZg9xxPSauaLf5aU?= =?us-ascii?q?7h/sTuqcLyl0iGp4dL+8hxu+61asx+PmWsSwzlpGtDdJn9bDu30Lyhfd8NKISu?= =?us-ascii?q?Fn8UekwTuP1x7c6uVDIU0si6rbMZkhwqMslpYOrUjPBC/3l1/3ja+XbUor4PKk?= =?us-ascii?q?6+L5bbX6vpOcNol0hR/iMqk2h8CyAuQ1PhIOUmWa4+iwyqHv8ELjTLhEkPE6iq?= =?us-ascii?q?zZv4rbJcQfqK65GQhV0oM75hmlCzepytUYnX8dIFJLYhKHjpPpNE3OIP3jCfew?= =?us-ascii?q?nVutkDZlx/DHJLHuHpLNLn3bnLf7Ybl981JcyBY0zd1H+51bELQBIPbqVk/1td?= =?us-ascii?q?zYFQM5Phevw+fnDdV9zpkRVXiOAq+fKqPSsEWH6vghI+mWfIMVvTH9JOU76PP2?= =?us-ascii?q?ln85nEMdfbGu3ZsKdHDrVshhdnSefXPpyv0IC2ENr0JqXev2gViIWCRVYGeaUK?= =?us-ascii?q?c15zV9A4WjW8OLZoerj7aGlBW7F5tZLjRGGFCFF3iyJtisUfMLbyeYL9Vu1DoJ?= =?us-ascii?q?Se7yZZUm0ESHsAb7zfJJNOvP8S1Q4Zvn3dlzoePJlAo59RRwAtSc3WDLRGZxyD?= =?us-ascii?q?BbDwQq1bxy9BQugmyI1rJ11rkBTYRe?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0ByAQBXPPpYgCDMOLldHAEBBAEBCgEBF?= =?us-ascii?q?wEBBAEBCgEBhAqBDINnm1whEJdjLIV4AoQLQhUBAQEBAQEBAQEBARIBAQsLCQg?= =?us-ascii?q?mMYIzIgGCQAECAyMEEUEQCxgCAiYCAlcGAQwIAQEQigwBCaldgWw6iyIBAQEBA?= =?us-ascii?q?QEBAQIBAQEBAQEBASCBC4VIgggLgmOHXYJfAQSdQYIQhQeLb4JViCCGYot4iB8?= =?us-ascii?q?CNYEoJh0gWYRpHIFlc4k2AQEB?= X-IPAS-Result: =?us-ascii?q?A0ByAQBXPPpYgCDMOLldHAEBBAEBCgEBFwEBBAEBCgEBhAq?= =?us-ascii?q?BDINnm1whEJdjLIV4AoQLQhUBAQEBAQEBAQEBARIBAQsLCQgmMYIzIgGCQAECA?= =?us-ascii?q?yMEEUEQCxgCAiYCAlcGAQwIAQEQigwBCaldgWw6iyIBAQEBAQEBAQIBAQEBAQE?= =?us-ascii?q?BASCBC4VIgggLgmOHXYJfAQSdQYIQhQeLb4JViCCGYot4iB8CNYEoJh0gWYRpH?= =?us-ascii?q?IFlc4k2AQEB?= X-IronPort-AV: E=Sophos;i="5.37,230,1488841200"; d="scan'208";a="221123227" Received: from vrout10.yaziba.net ([185.56.204.32]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 21 Apr 2017 19:11:41 +0200 Received: from mtaout10.int.yaziba.net (mtaout10.int.yaziba.net [10.4.20.36]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by vrout10.yaziba.net (mx10.yaziba.net) with ESMTPS id B213752033; Fri, 21 Apr 2017 19:11:40 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mtaout10.int.yaziba.net (Postfix) with ESMTP id CA5741603F0; Fri, 21 Apr 2017 19:11:40 +0200 (CEST) X-Virus-Scanned: amavisd-new at Received: from mtaout10.int.yaziba.net ([127.0.0.1]) by localhost (mtaout10.int.yaziba.net [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 1eP1bSBwgMS6; Fri, 21 Apr 2017 19:11:40 +0200 (CEST) Received: from [10.0.210.211] (unknown [185.23.92.144]) by mtaout10.int.yaziba.net (Postfix) with ESMTPSA id 9C75B16039B; Fri, 21 Apr 2017 19:11:40 +0200 (CEST) To: Yotam Barnoy , Hongbo Zhang References: <58FA282A021A076200390603_0_57023@msllnjpmsgsv06> Cc: Ocaml Mailing List From: Alain Frisch Message-ID: <703d59cf-a1f9-c12f-9325-44aa23b03e36@lexifi.com> Date: Fri, 21 Apr 2017 19:11:38 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-DRWEB-SCAN: ok X-VRSPAM-SCORE: -100 X-VRSPAM-STATE: legit X-VRSPAM-CAUSE: gggruggvucftvghtrhhoucdtuddrfeeliedrfeeggdduudegucetufdoteggodetrfcurfhrohhfihhlvgemucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefuvfhfhffkffgfgggjtgfgsehtjeertddtfeejnecuhfhrohhmpeetlhgrihhnucfhrhhishgthhcuoegrlhgrihhnrdhfrhhishgthheslhgvgihifhhirdgtohhmqeenucffohhmrghinhepghhithhhuhgsrdgtohhmnecukfhppedukeehrddvfedrledvrddugeegnecurfgrrhgrmhepmhhouggvpehsmhhtphhouhht X-VRSPAM-EXTCAUSE: mhhouggvpehsmhhtphhouhht Subject: Re: [Caml-list] PPX is harmful to our community in the long term On 21/04/2017 18:04, Yotam Barnoy wrote: > My 2 cents: I personally think we did PPX wrong. PPX should have used > the syntax as its starting point for full backwards compatibility. > Currently, the PPX cycle is > > OCaml: { syntax -> AST -> serialized AST } -> PPX: {serialized AST -> > AST -> PPX modification -> serialized AST} -> OCaml: {serialized AST > -> AST -> ... } > > Exposing the AST is the cause of the problem you mention. If instead, > every PPX extension had a particular OCaml compiler's syntax parser > and syntax printer integrated into it, and the PPX cycle was: > > PPX: { syntax -> AST -> PPX modification -> syntax } -> compiler: { > syntax -> AST -> ...} > > We would have far fewer issues with PPX plugins, since they would be > as backwards-compatible as the syntax. I think https://github.com/let-def/ocaml-migrate-parsetree is a much stronger approach. If I understand correctly, Jane Street moved from using a migration system based on concrete syntax to using this new project. In your suggested approach, imagine you have a PPX processor written for OCaml 4.04. It assumes that the Parsetree it works on is the one of 4.04. Sure, you can compile this PPX processor (+ embedded parser/printer) into a stand-alone executable, using OCaml 4.04, and then apply it as a preprocessor called from OCaml 4.05. But this is very impractical: users would need to install OCaml 4.04 just to produce the PPX executable. Moreover, you loose the ability to combine multiple rewritings in a single process, and you have to pay the price of multiple parsing/printing/processes. On top of that: (i) you put in the critical loop "pprintast.ml", which has always been more or less buggy; (ii) there is no hope that an "old PPX" applies to source code using newest syntactic features; (iii) as you mention, locations would need to be added for each node in the AST, which makes the parsing/printing even slower; moreover, it is not technically straightforward to do so, since many places in the AST contains locations but do not support attaching attributes; (iv) we loose the ability to change the concrete syntax of OCaml, either to use alternative syntaxes such as Reason, or to remove, at some point, weird corner cases in the current syntax. With ocaml-migrate-parsetree, you can still compile your PPX written for 4.04 with newer versions of OCaml. And it would even be possible (I don't know if this is already the case) to apply it to source code using newer syntactic features, as long as the rewriting done by the PPX doesn't interact with those features. (This could be achieved by turning new syntactic features into attributes/extension nodes when mapping to the older AST; and then recognizing these forms and reconstitute the correct new AST forms when mapping back to the new version.) -- Alain