Re: Woah

From: Date: Mon, 10 Sep 2001 21:38:44 +0000
Subject: Re: Woah
References: 1 2  Groups: php.dev 
Request: Send a blank email to php-dev+get-65703@lists.php.net to get a copy of this message
Here's a functional alias_function call which duplicates a functions entry in the global function table (ripped from APD with minor mods). PHP_FUNCTION(alias_function) { zval **z_orig_fname, **z_new_fname; zend_function *func, *dummy_func; if( ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &z_orig_fname, &z_new_fname) == FAILURE ) { ZEND_WRONG_PARAM_COUNT(); } convert_to_string_ex(z_orig_fname); convert_to_string_ex(z_new_fname); if(zend_hash_find(EG(function_table), Z_STRVAL_PP(z_orig_fname), Z_STRLEN_PP(z_orig_fname) + 1, (void **) &func) == FAILURE) { zend_error(E_WARNING, "alias(%s, %s) failed: %s does not exist!", Z_STRVAL_PP(z_new_fname), Z_STRVAL_PP(z_orig_fname), Z_STRVAL_PP(z_orig_fname)); RETURN_FALSE; } if(zend_hash_find(EG(function_table), Z_STRVAL_PP(z_new_fname), Z_STRLEN_PP(z_new_fname) + 1, (void **) &dummy_func) == SUCCESS) { zend_error(E_WARNING, "alias(%s, %s) failed: %s already exists!", Z_STRVAL_PP(z_new_fname), Z_STRVAL_PP(z_orig_fname), Z_STRVAL_PP(z_new_fname)); RETURN_FALSE; } if(zend_hash_add(EG(function_table), Z_STRVAL_PP(z_new_fname), Z_STRLEN_PP(z_new_fname) + 1, func, sizeof(zend_function), NULL) == FAILURE) { zend_error(E_WARNING, "Failed to insert %s into EG(function_table)", Z_STRVAL_PP(z_new_fname)); RETURN_FALSE; } RETURN_TRUE; } ----- Original Message ----- From: "Wez Furlong" <wez@thebrainroom.com> To: "James Moore" <jmoore@php.net> Cc: <jim@jaguNET.com>; <php-dev@lists.php.net>; "Zeev Suraski" <zeev@zend.com> Sent: Monday, September 10, 2001 5:23 PM Subject: Re: [PHP-DEV] Woah > On 08/09/01, "James Moore" <jmoore@php.net> wrote: > > I think that echo is used > > a lot more so lets make echo aliased as ^(.....) oh and perhaps we should > > have sprintf as *() and dont forget while.. I bet perople get bored of > > typing that so lets make it >(conditional expreesion) ................} > > No, no, no, no! :-) > The people here arguing for the _() gettext alias are NOT suggesting that > we alias everything with insane single character aliases. > > It's about _() being the standard for gettext. The gettext code processing > tools also use it. Yes I agree that to someone that hasn't used it before > it's confusing, but so what? Put it in the manual and the confusion goes > away. > > I don't think deprecating it will make the problem go away: people will > still use it because a) all their other code uses it and b) thats the > way you do things with gettext c) A page full of the word gettext is > certainly harder for a person to parse and read the meaning of their > localized text than an inobtrusive _ character. > > So, if we remove the falias people will still put their own in and all the > PHP code will end up looking the same so the net effect is that we have > slowed down the PHP code, added a function and not changed the readability > or namespace pollution. > > So what exactly are we arguing about^H^H^H^H^H^H^H^H^H^H^H^H^H discussing > here? That _() is evil and should go, or that we definitely don't want > anything else like it in the future? > I think/hope that it is the latter. > > If the purists have their way and remove the alias (even if it is a long > time away), then we can offer one of the following solutions: > 1. Allow a way for PHP code to tell the zend engine that an identifier is > now a function alias. > 2. Create a php config directive that allows you to do the same thing > 3. Force the user to declare their function but have the zend engine > optimize the function call to call the aliased function. > > I like the idea of the last option if you're into readability, although > the first two are likely to be a few cycles faster overall (there is no > need to parse the function call to setup that alias). > > I still maintain that losing _() won't buy PHP anything, but agree that > we should not let any other single character alias creep in there. > > --Wez. > > > -- > PHP Development Mailing List <http://www.php.net/> > To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net > For additional commands, e-mail: php-dev-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.dev (#65703) next »