Re: Calling symbol table patch
| From: | Andrei Zmievski | Date: | Mon, 20 Nov 2000 20:35:56 +0000 |
| Subject: | Re: Calling symbol table patch | ||
| References: | 1 2 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-38670@lists.php.net to get a copy of this message | ||
On Mon, 20 Nov 2000, Andi Gutmans wrote:
> Andrei,
>
> The patch slows down the main function call opcode. I really don't like that.
How much really does it slow it down? It's just putting a pointer on a
stack before the actual call and taking it off afterwards.
> Is it really that important? When did you bump into this need and why
> couldn't you handle it with the existing functionality? I'm not quite clear
> as to when in programming you *need* such functionality and can't write the
> code in a different (IMO better) way.
> But then again, you might have a very good reason because I don't know
> when/how this need arose.
It's impossible to implement some functionality without some sort of a
patch like this. For example, I am working on a template engine, and I
need to assign a variable to the template, and I got sick of typing
something like this:
$tpl->assign('foo', $foo);
So, I wanted to speed it up and have a method that could take just names
of the variables and assign them using their current values in the
calling scope, like this:
$tpl->batch_assign('foo', 'bar', 'color1');
But there is no way to get to calling scope:
class Template {
function batch_assign() {
$args = func_get_args();
foreach ($args as $var_name) {
/* Right here, we have no idea what $$var_name is in the
* function that called us. */
}
}
}
So, that's why I wanted that patch.
-Andrei
Nobody tried to design Windows - it just grew in random
directions without any kind of thought behind it.