Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:76306 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 34820 invoked from network); 1 Aug 2014 20:41:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Aug 2014 20:41:12 -0000 Authentication-Results: pb1.pair.com header.from=julienpauli@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=julienpauli@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.174 as permitted sender) X-PHP-List-Original-Sender: julienpauli@gmail.com X-Host-Fingerprint: 209.85.220.174 mail-vc0-f174.google.com Received: from [209.85.220.174] ([209.85.220.174:59619] helo=mail-vc0-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B8/12-23250-76BFBD35 for ; Fri, 01 Aug 2014 16:41:12 -0400 Received: by mail-vc0-f174.google.com with SMTP id la4so7658642vcb.19 for ; Fri, 01 Aug 2014 13:41:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=L4eSRi1ACr2+56tWUc4RABnJAuJS8xtXld+KLI6XxwE=; b=rKGCJ3aY8soXHiw3MNFiJDmMtewTlFhwHItUz/7duwpZga2jGsdbfcybQnPQ4oqq2/ 3Uv8Lo9tN/SPtsYLwEVc2OAm2BqTLP+ZQ93zr9LbPxWFJYkzpShMnlxSun/1f6XpA1yy lws1aqlG5V/3i5d2TdFti70O4YxzQYbIBKLD3OVY3h/vzIYAba1eTiYos4DQy6bYSb9r D9olC6NGWhbb5cxYP2ixU6j5xS8cZgJuH/hvXjbDoxLdfMQspzhAH0puCuFefgrk5nGA dIWqUvxvC6GVi5+RGYrS3P1Hggs0ifQlfRmAuHb+A7x6UpCHZaCmTQBCovBgO2B2uIgr gGag== X-Received: by 10.52.9.35 with SMTP id w3mr3674440vda.12.1406884959750; Fri, 01 Aug 2014 02:22:39 -0700 (PDT) MIME-Version: 1.0 Sender: julienpauli@gmail.com Received: by 10.220.30.70 with HTTP; Fri, 1 Aug 2014 02:21:59 -0700 (PDT) In-Reply-To: <3F1B2834-3939-4F86-86E0-207D2CE469D6@ajf.me> References: <3F1B2834-3939-4F86-86E0-207D2CE469D6@ajf.me> Date: Fri, 1 Aug 2014 11:21:59 +0200 X-Google-Sender-Auth: A4URDMITFOYIA1SHZSUn7W44E3A Message-ID: To: Andrea Faulds Cc: Nikita Popov , PHP internals Content-Type: multipart/alternative; boundary=20cf302ef9f6440e0604ff8deeb6 Subject: Re: [PHP-DEV] [RFC] Introduce Abstract Syntax Tree From: jpauli@php.net (Julien Pauli) --20cf302ef9f6440e0604ff8deeb6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Thu, Jul 31, 2014 at 9:03 PM, Andrea Faulds wrote: > > On 31 Jul 2014, at 19:11, Nikita Popov wrote: > > > I've created a draft RFC and implementation for the introduction of an > > Abstract Syntax Tree (AST) as an intermediate structure in our > compilation > > process: > > Oh man, you got the implementation done? That makes me so happy. ^^ > > Like Sara, I am very, very much for this. There are so many potential > benefits, and the only real downside IMO (memory use and performance at > parsing-time) is largely negated by using opcache, a built-in feature of > PHP. An AST is really the most obvious and best way to do compilation, IM= O, > and as it so happens, I=E2=80=99ve used them in the past when implementin= g a > programming language I designed. > > A benefit I particularly like is we could perhaps add nicer generator > expression and list() syntaxes, as you have described. I can=E2=80=99t re= member if > you implemented the former. If you did, I=E2=80=99d love it if you=E2=80= =99d also propose > it should ASTs get in, they=E2=80=99re an awesome feature and it is a sha= me we > didn=E2=80=99t get them when we got generators. > > On another note, while we *could* allow extensions to hook into the AST, > I=E2=80=99d stray away from letting them modify it and implement new feat= ures. That > really doesn=E2=80=99t sound like a good idea at all (I could elaborate o= n why, but > I won=E2=80=99t bother unless someone asks me). Letting them read it woul= d clearly > be a good thing though. Side note: Would that obsolete your PHP-Parser > userland library once an extension allows reading the AST? If an extensio= n > is written, perhaps it should have the same API as your library had. I > believe many projects already use it. > > On an *implementation* note, I assume this is based on the existing > constant ASTs, unless you renamed it to something other then zend_ast. Do= es > this cause any problems for them? While I can see the benefits of course, > I=E2=80=99d just like to be sure that the validator doesn=E2=80=99t let a= nything slip > through. > > It=E2=80=99s also nice to see zend_emit_op and _jump, I suspect they=E2= =80=99ll make code > easier to read (currently I have to scan for the other operands sometimes > as they=E2=80=99re not always set together). > > Again, I really like this. I look forward to its inclusion. Thank you so > much! > > -- > Andrea Faulds > http://ajf.me/ > > > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > That's nice Nik ;-) As I told you on IRC, I'm all in for developping an extension that could play with the AST. I like Andrea's suggestion of publishing to userland an API that looks like PHPParser :-) Julien.P --20cf302ef9f6440e0604ff8deeb6--