Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:76312 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 10691 invoked from network); 2 Aug 2014 20:44:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Aug 2014 20:44:25 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.218.53 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.218.53 mail-oi0-f53.google.com Received: from [209.85.218.53] ([209.85.218.53:50383] helo=mail-oi0-f53.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A7/40-02246-4AD4DD35 for ; Sat, 02 Aug 2014 16:44:25 -0400 Received: by mail-oi0-f53.google.com with SMTP id e131so3659824oig.40 for ; Sat, 02 Aug 2014 13:44:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=MeF4xpBT4Xmt6mzkCfr6cLJZkaZTb57+lUI/eGIg1FE=; b=N/5fV5/R+tPQNVvxNWLFhNUfXyC4tM30XvOirWXtPu3PtXkeQQe13JZe/VuSIG5FII 5ZCYXDJlPIE86ql+W/OEUnJGYT+0bxWCLBf3A5C4Ym7jlENW4tinpw1RONEBkCQz1KMm jERarvLeseZRb+XK1OQBIPcMH9/cfxbis+CLtZL7JTz6QQfDXnFjLpsJUxXEl8rsP55B hX+jYEcIoxF3I8eYrMEwbXh/45jo0H0ECNi2W9T8lYALGv2OTa5HiFqC9w1i6yTX7rs3 XjLyuvZU/HlyPzuHRCQUDAaVnrKYUwjGiREUfolmEwGfh+L/5ikZeuUmXG/XBLnPpax9 z7Ng== MIME-Version: 1.0 X-Received: by 10.182.60.98 with SMTP id g2mr18545372obr.6.1407012281432; Sat, 02 Aug 2014 13:44:41 -0700 (PDT) Received: by 10.182.65.229 with HTTP; Sat, 2 Aug 2014 13:44:41 -0700 (PDT) In-Reply-To: <3F1B2834-3939-4F86-86E0-207D2CE469D6@ajf.me> References: <3F1B2834-3939-4F86-86E0-207D2CE469D6@ajf.me> Date: Sat, 2 Aug 2014 22:44:41 +0200 Message-ID: To: Andrea Faulds Cc: PHP internals Content-Type: multipart/alternative; boundary=089e0158aaa03ac01304ffab937d Subject: Re: [PHP-DEV] [RFC] Introduce Abstract Syntax Tree From: nikita.ppv@gmail.com (Nikita Popov) --089e0158aaa03ac01304ffab937d 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 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). Why do you think this isn't a good idea? I think it would be a nice way to prototype language features before pulling them into PHP. Though admittedly I don't think there are many things that could be implemented that way. > 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 hav= e > the same API as your library had. I believe many projects already use it. > A native extension has the limitation that it will not be able to parse files for newer PHP versions (which, depending on the use case may or may not be a problem) and probably won't provide a stable structure across versions. At least I think giving BC guarantees on the AST structure between minor versions would be way too limiting for us. As such I think both a native ext (which provides awesome perf) and PHP-Parser (which provides x-compat) have their place ;) > 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. > Yes, the AST structure is based on the existing work on constant scalar expressions, though by now the structure and API deviate a good bit from that. It doesn't cause problems for them - constant expressions go through a validation that checks that only valid nodes are used and adjusts those nodes that have special representation for the constexpr case (e.g. constant and class constant access). Nikita --089e0158aaa03ac01304ffab937d--