Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

SitePoint PHP Blog:
Re-Implementing the Range Operator in PHP
Mar 09, 2016 @ 18:21:08

The SitePoint blog has a new post that revisits a previous tutorial about implementing a custom operator - the "range" operator - natively in PHP itself. In this new article (again, a repost from the article by Thomas Punt) he comes back and refines the implementation a bit to fix some of the issues with the previous version.

In the prequel to this article (hint: make sure you’ve read it first), I showed one way to implement a range operator in PHP. Initial implementations, however, are rarely the best, and so it is the intention of this article to look at how the previous implementation can be improved.

He starts by mentioning some of the drawbacks to the previous implementation, mostly that the computation of the value would only happen at runtime (slower) and not compile time. He then goes through the code from before and shares the updates to make that allow this compile-time option to work on the lexer, parser and adding in new code for the compilation stage. Finally he makes the updates the Zend VM to allow for these changes to take effect.

tagged: reimplement range operator tutorial source update

Link: http://www.sitepoint.com/re-implementing-the-range-operator-in-php/


Trending Topics: