Hi,

In my attempt to build a ZEP to PHP translator (https://github.com/test-to-com/zephir) I ran into a simple problem.

Even though ZEP is very similar to PHP, it does change things a bit. In most cases I assume these changes are optimizations to the way PHP did things, but also to try to make PHP more consistent.

Changes like: 1. 'isset' in ZEP is not the same as 'isset' in PHP, or 2. 'typeof' in ZEP is not the same as 'gettype()' in PHP

most of these modifications are handled as internal functions added by the ZEP Platform (ex: zephirisset{something or other}). These base functions serve as the core for other extensions.

The problem is, when I built, the translator I implemented a similar as ZEPHIR did (i.e. I translated these ZEP operators to PHP function calls). In some cases I directly used what I though was the PHP equivalent (i.e. typeof === gettype()) in other cases I used an intermediate PHP function (i.e. isset === zephir_isset**).

Even though this works in most cases, it add another level of problem in that, my PHP translations might not actually perform exactly as the zephir_* versions.

I had this problem when debugging my PHP version of PHALCON. I noticed that ZEP typeof var , where 'var' is undefined returns 'null' where as PHP throws a warning and returns 'NULL'. Enough of a difference for PHALCON to have vailed the 'if'.

So how do you solve this? I guess the options you have are: 1. Provide better translations of all the zephir_* functions, or 2. Use the ACTUAL Zephir function...

I think it would be great if, for debug purposes or maybe even more, we could produce a base 'zephir' extension, that added these 'base' functions to PHP so that the ZEP -> PHP translator could directly used them, instead of having to do a manual translation (no more BUGS or inconsistencies due to translation)..

The problem is actually more extensive in that the PHALCON extension, also adds a series of functions (ex: Parsers based on lemon for PHQL and VOLT), as well as some other optimization functions. I would love to have a 'debug' build, that generated an extension with just these C, not ZEP, functions so that when I ran the PHP version of PHALCON, I could fully debug the extension.

I guess that, I could just simply pair down the current ZEP build to make my 'zephir-dbg' and 'phalcon-dbg' extension. But this is a manual solution, which I'm going to have to maintain in sync with the original repositories, not something I would like to do always. Secondly, the actual C extension code, is not very readable or easy to build (also have to take into consideration, extension globals).

As a side note, using http://www.php-cpp.com as the base for the zep generated extension will probably make the extensions easier to read and build (just don't know the cost of the overhead).