On Thu, Jul 31, 2014 at 9:03 PM, Andrea Faulds <a...@ajf.me> wrote:

>
> On 31 Jul 2014, at 19:11, Nikita Popov <nikita....@gmail.com> 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’ve 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’t remember if
> you implemented the former. If you did, I’d love it if you’d also propose
> it should ASTs get in, they’re an awesome feature and it is a shame we
> didn’t get them when we got generators.
>
> On another note, while we *could* allow extensions to hook into the AST,
> I’d stray away from letting them modify it and implement new features. That
> really doesn’t sound like a good idea at all (I could elaborate on why, but
> I won’t 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’d just like to be sure that the validator doesn’t let anything slip
> through.
>
> It’s also nice to see zend_emit_op and _jump, I suspect they’ll make code
> easier to read (currently I have to scan for the other operands sometimes
> as they’re 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

Reply via email to