Re: Re: [apd][patch] Two new functions: override_constant() and rename_constant()

From: Date: Mon, 13 Sep 2004 23:29:16 +0000
Subject: Re: Re: [apd][patch] Two new functions: override_constant() and rename_constant()
References: 1 2  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-1333@lists.php.net to get a copy of this message
You have to realize that setting a constant is significantly slower than setting a regular variable though. -Rasmus On Mon, 13 Sep 2004, DvDmanDT wrote: > I like the idea of being able to do these things _while debugging_.. I love > constants due to the fact that they exist in all scopes, and I use them > pretty much in my scripts.. For example I use them for storing the user id > of the logged in user at one place, and it's 0 if noone is logged in.. I > display different things depending on wether that constant is 0 or not.. > While debugging sometimes I might need to show one thing and not the other > one.. At the moment I do this: if(1||CONSTANT) or id(0&&CONSTANT) to > override these if's, and replace all occurences inside that block.. Would've > been much easier to debug these problems I have by just changing the value > over 30 lines.. > > -- > // DvDmanDT > MSN: dvdmandt¤hotmail.com > Mail: dvdmandt¤telia.com > "Johannes Schlueter" <johannes@php.net> skrev i meddelandet > news:200409120137.28637@schlueters.de... > > Hi George, > > > > while trying to understand an application I got a bit frustrated that I > can > > rename functions using apd and change classes using classkit but that I > can't > > change constants. So I wrote a small patch for apd adding two small > functions > > which can change constants. > > > > The protos are quite similar to override_function and rename_function: > > > > /* {{{ proto bool override_consant(string name, mixed value) > > overrides the content of the constant name with value */ > > > > /* {{{ proto bool rename_constant(string oldname, string newname) > > renames the constant oldname to newname */ > > > > A small example looks like > > > > <?php > > define('FOO', 'asdf'); > > > > rename_constant('FOO', 'BAR'); > > override_constant('BAR', 'qwerty'); > > > > echo BAR; > > ?> > > > > This echos "qwerty". > > > > Maybe you like the idea and maybe even (parts of) the implementation it. > ;-) > > > > johannes > > > > -- > PECL development discussion Mailing List (http://pecl.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.pecl.dev (#1333) next »