zend_compile_string() usage within code
| From: | Clint Priest | Date: | Tue, 29 May 2012 03:10:24 +0000 |
| Subject: | zend_compile_string() usage within code | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-60686@lists.php.net to get a copy of this message | ||
Has anyone ever used the zend_compile_string() within the c code for compiling internally created
php? Is it frowned upon or has it never come up before?
In writing the accessors code I have several parts that are effectively just mimicking what a simple
zend_compile_string() would accomplish in a single line. It may be just as efficient as writing the
zend_do_begin_variable_parse() ... etc lines myself but would have the added benefit of changing as
the language changed as well.
More specific example:
Automatic implementation for a getter, would be something like this:
public $a {
get; /* Equivalent to "return $this->__a */
set; /* Equivalent to "$this->__a = $value; */
}
I would simply CG(active_op_array) = zend_compile_string("return $this->__a;", ...);
Thoughts?
-Clint