ID: 33418
User updated by: alex-spam at rdc dot ru
Reported By: alex-spam at rdc dot ru
Status: Wont fix
Bug Type: Feature/Change Request
Operating System: all
PHP Version: 4.3.11
New Comment:
Hope that may become possible in future versions of Zend Engine.
Thank you for your comments.
Previous Comments:
------------------------------------------------------------------------
[2005-06-21 13:28:44] [EMAIL PROTECTED]
Yes, I get what you want... but it's impossible to implement. You can't
insert compiled code INTO the current scope - that's just not possible
with the Zend Engine. (and it would require way too much work to do
this.
------------------------------------------------------------------------
[2005-06-21 13:03:11] alex-spam at rdc dot ru
I'm not a PHP internals expert so I can't get into detail on how
'precompiled evals' can be implemented.
No matter how it's named or implemented, the desired functionality
would allow a programmer to:
- build a piece of code in CURRENT context and prepare it for execution
(compile, bind all variables, functions etc.)
- execute this code using a lightweight language construct
'Preparation' process may have limitations, e.g. all referenced
variables must already be created, etc. In this case eval_prepare()
might just return FALSE with an appropriate error message.
Creating anonymous functions or using eval() are great by themselves,
but not for optimization purposes. I hope you've got my idea.
------------------------------------------------------------------------
[2005-06-21 12:54:29] [EMAIL PROTECTED]
New OpArrays (like your eval thing returns) can only be executing by
calling a function (or something that resembles it very closely)... so
you're not gaining anything here.
------------------------------------------------------------------------
[2005-06-21 12:43:39] alex-spam at rdc dot ru
create_function() will create a _function_. When we're talking tough
optimization, every extra function call is an issue.
On 10k calls strcmp() is MUCH slower than '==' operator on strings.
Function calls are quite expensive in PHP. The context is switched and
caller's variables become invisible.
Precompiled eval()s would allow to unroll small loops without changing
the context, which is also important. What do you think?
------------------------------------------------------------------------
[2005-06-21 11:36:32] [EMAIL PROTECTED]
You could use create_function() to create your dynamic
code and execute the returned function. No need for a new
function.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/33418
--
Edit this bug report at http://bugs.php.net/?id=33418&edit=1