Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:76298 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 38436 invoked from network); 31 Jul 2014 19:03:03 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 Jul 2014 19:03:03 -0000 Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 192.64.116.216 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 192.64.116.216 imap10-3.ox.privateemail.com Received: from [192.64.116.216] ([192.64.116.216:60170] helo=imap10-3.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 86/63-09748-6E29AD35 for ; Thu, 31 Jul 2014 15:03:03 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.privateemail.com (Postfix) with ESMTP id CE5972400D1; Thu, 31 Jul 2014 15:03:18 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at imap10.ox.privateemail.com Received: from mail.privateemail.com ([127.0.0.1]) by localhost (imap10.ox.privateemail.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id uuoI0jfTJXNC; Thu, 31 Jul 2014 15:03:18 -0400 (EDT) Received: from [192.168.0.15] (unknown [90.210.122.167]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.privateemail.com (Postfix) with ESMTPSA id 8DD5A2400D7; Thu, 31 Jul 2014 15:03:17 -0400 (EDT) Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) In-Reply-To: Date: Thu, 31 Jul 2014 20:03:14 +0100 Cc: PHP internals Content-Transfer-Encoding: quoted-printable Message-ID: <3F1B2834-3939-4F86-86E0-207D2CE469D6@ajf.me> References: To: Nikita Popov X-Mailer: Apple Mail (2.1878.6) Subject: Re: [PHP-DEV] [RFC] Introduce Abstract Syntax Tree From: ajf@ajf.me (Andrea Faulds) 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, = IMO, and as it so happens, I=92ve used them in the past when = implementing 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=92t = remember if you implemented the former. If you did, I=92d love it if = you=92d also propose it should ASTs get in, they=92re an awesome feature = and it is a shame we didn=92t get them when we got generators. On another note, while we *could* allow extensions to hook into the AST, = I=92d stray away from letting them modify it and implement new features. = That really doesn=92t sound like a good idea at all (I could elaborate = on why, but I won=92t bother unless someone asks me). Letting them read = it would 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 extension 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. = Does this cause any problems for them? While I can see the benefits of = course, I=92d just like to be sure that the validator doesn=92t let = anything slip through. It=92s also nice to see zend_emit_op and _jump, I suspect they=92ll make = code easier to read (currently I have to scan for the other operands = sometimes as they=92re not always set together). Again, I really like this. I look forward to its inclusion. Thank you so = much! -- Andrea Faulds http://ajf.me/