Re: Calling symbol table patch
| From: | Sterling Hughes | Date: | Tue, 21 Nov 2000 14:54:42 +0000 |
| Subject: | Re: Calling symbol table patch | ||
| References: | 1 2 3 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-38826@lists.php.net to get a copy of this message | ||
At 08:29 AM 11/21/2000 -0600, Andrei Zmievski wrote:
On Mon, 20 Nov 2000, Sterling Hughes wrote: Maybe I explained it wrong (this timezone difference in italy is killing me, I'm less coherent than usual), I meant it would just return the names of all the variables in the global scope to keep compatibility but then return the names and the contents of the variables in the current scope. The only justification for this is not to break what little backwards compatibility is neccessary, and the semantics just don't make sense to me... Your functions were introduced after 4.0.3. As far as I'm concerned, you can totally change the behavior of the function because it has not been released it. Secondly, I still maintain that get_defined_vars() should return current scope only - it is not simply a debugging tool, it is a way to get the whole symbol table to pass to another function, as in my case. Do not even mention the globals anywhere in that function.Right, I realize now its more for debugging, but when I wrote it I didn't use it for more, Well I did say it was a bad idea :) If it got introduced after 4.0.3 then I agree, its completely changeable.
You want to explain to an HTML coder learning PHP Zend's symbol tables and how it relates, be my guest (I'll take the death by fire personally ;). I think get_defined_vars() gives a clearer indication of what its supposed to do (give me all of the currently defined variables). Then you've already confused HTML code by mentioning "global" vs. "current" scope variables.Still, I'm sure there are people on this list who don't understand what a symbol table is, whereas scope is clearly defined in the documentation and is a "PHP" thing. get_defined_vars() is very simple "get me currently defined variables" whereas get_symbol_table() says to me "get me a symbol table". I think modifying get_defined_vars() to just return the current scope is the best option: /* {{{ proto array get_defined_vars(void) Returns an associative array of names and values of all currently defined variable names (variables in the current scope) */ ZEND_FUNCTION(get_defined_vars) {
zval *tmp;
array_init(return_value);
zend_hash_copy(return_value->value.ht, EG(active_symbol_table),
(copy_ctor_func_t)zval_add_ref, &tmp, sizeof(zval *));
}
/* }}} */
-Sterling