Re: New zend_compile.c to solve all of the duplicate function problems

From: Date: Fri, 19 Oct 2001 14:04:36 +0000
Subject: Re: New zend_compile.c to solve all of the duplicate function problems
References: 1 2 3  Groups: php.dev 
Request: Send a blank email to php-dev+get-68389@lists.php.net to get a copy of this message
Can we at least confirm that this works in the current release candidate? It works fine on my build, but Rasmus is having problems with it. test.php ===== <?php include 'testlib.php'; include 'testlib.php'; test(); ?> testlib.php ====== <?php if (!defined('_TESTLIB_PHP')) { define ('_TESTLIB_PHP', 1); function test() { print "Function test()\n"; } } ?> > If we were designing the language from the ground up I would agree with you. > However, we are talking about a language that is already being used by lots > of people. Therefore I see no reason to break the old code. > > Brian Moon > ---------------------------------------------------------------------- > dealnews.com, Inc. > Makers of dealnews, dealmac > http://dealnews.com/ | > http://dealmac.com/ > > > ----- Original Message ----- > From: "Edin Kadribasic" <edink@proventum.net> > To: "Rasmus Lerdorf" <rasmus@php.net> > Cc: "Stanislav Malyshev" <stas@zend.com>; "Daniel Beckham" > <danbeck@dealnews.com>; "Brian Moon" <brianm@dealnews.com>; "PHP > Development" <php-dev@lists.php.net> > Sent: Friday, October 19, 2001 5:22 AM > Subject: Re: [PHP-DEV] New zend_compile.c to solve all of the duplicate > function problems > > > > I guess I do not understand. The following example works just fine in PHP > > 4.1.0RC1: > > > > test.php > > ===== > > <?php > > include 'testlib.php'; > > include 'testlib.php'; > > test(); > > ?> > > testlib.php > > ====== > > <?php > > if (!defined('_TESTLIB_PHP')) { > > define ('_TESTLIB_PHP', 1); > > > > function test() { > > print "Function test()\n"; > > } > > } > > ?> > > > > This however does not work and IMHO should not work. (It did work on PHP > > 4.0.6) > > testlib.php > > ====== > > <?php > > if (!defined('_TESTLIB_PHP')) { > > define ('_TESTLIB_PHP', 1); > > return; > > } > > function test() { > > print "Function test()\n"; > > } > > ?> > > > > The second example utilises the fact that the script compiling stoped at > > return, while now it does not. I really fail to see what's wrong with > using > > the first example and how that cannot be used for preventing multiple > > function definitions. > > > > > > Edin > > > > > It is valid in the sense that the code would not be executed the second > > > time, but it isn't valid for preventing multiple function definitions > > > inside that block. ie. no conditional function definitions. > > > > > > -Rasmus > > > > > > On Fri, 19 Oct 2001, Edin Kadribasic wrote: > > > > > > > > Since you can no longer do: > > > > > > > > > > if(!defined(_FOO_INC)): > > > > > define('_FOO_INC',1); > > > > > > > > > > ... > > > > > > > > > > endif; > > > > > > > > > > to protect a file from multiple inclusion within the file itself, > some > > > > > > > > This is still a valid construct. I could find nothing in the > discussion > > that > > > > would indicate otherwise. The only thing that does not work now, and > it > > did > > > > before was: > > > > > > > > if(!defined(_FOO_INC)): > > > > define('_FOO_INC',1); > > > > return; > > > > endif; > > > > ... > > > > ... > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > 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 (#68389) next »