Re: Calling symbol table patch

From: Date: Mon, 20 Nov 2000 20:40:37 +0000
Subject: Re: Calling symbol table patch
References: 1 2 3  Groups: php.dev 
Request: Send a blank email to php-dev+get-38675@lists.php.net to get a copy of this message
At 02:35 PM 11/20/2000 -0600, Andrei Zmievski wrote:
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. */
                }
        }
}
I don't think its really a good idea for a function to have access to the scope of the function that called it (and be able to modify it). That just makes me a little queasy somehow. You shouldn't be able to modify and access one functions scope from another function. -Sterling

« previous php.dev (#38675) next »