RE: [PHP-DEV] RE: PHP 4.0 Bug #9064 Updated: Functions inside fun ctions cause errors if the outer function is called twice.

From: Date: Fri, 02 Feb 2001 19:11:42 +0000
Subject: RE: [PHP-DEV] RE: PHP 4.0 Bug #9064 Updated: Functions inside fun ctions cause errors if the outer function is called twice.
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-45634@lists.php.net to get a copy of this message
Sam Liddicott writes: > > > > -----Original Message----- > > From: Lars Torben Wilson [mailto:torben@php.net] > > Sent: Friday, February 02, 2001 09:49 > > To: Christopher Kings-Lynne > > Cc: Bug Database > > Subject: Re: [PHP-DEV] RE: PHP 4.0 Bug #9064 Updated: Functions inside > > functions cause errors if the outer function is called twice. > > > > > > > > What does that buy you that this doesn't? > > > > function test2() { > > echo "hi"; > > } > > > > function test() { > > test2(); > > } > > > > ...other than a new scoping rule? > > Don't underestimate scoping, it means you can have multiple test2()'s [lest > call it "sort" - common to use different sort routines in different > circumstances] > > a) stops namespace polution > b) keeps access private > while > c) retaining modularisation. > > Sam I didn't underestimate scoping per se (or at least I didn't intend to). However, this particular manifestation isn't really one that I would consider highly indispensable. :) For the style of language that it is, I think PHP's current scoping really isn't all that deficient, although there are certainly times when a more complete namespace/module/scoping scheme would come in handy. Torben > > > > > > Christopher Kings-Lynne writes: > > > Shouldn't you at least be able to register the "nested > > function" as 'static? > > > > > > This causes syntax errors in 4.0.4pl1. > > > > > > ie: > > > > > > <?php > > > > > > function test() { > > > static function test2() { > > > echo "hi"; > > > } > > > > > > test2(); > > > } > > > > > > test(); > > > test(); > > > test(); > > > > > > ?> > > > > > > > -----Original Message----- > > > > From: Bug Database [mailto:php-dev@lists.php.net] > > > > Sent: Friday, February 02, 2001 5:14 PM > > > > To: chriskl@familyhealth.com.au > > > > Subject: PHP 4.0 Bug #9064 Updated: Functions inside > > functions cause > > > > errors if the outer function is called twice. > > > > > > > > > > > > ID: 9064 > > > > Updated by: hholzgra > > > > Reported By: chriskl@familyhealth.com.au > > > > Old-Status: Open > > > > Status: Closed > > > > Bug Type: Scripting Engine problem > > > > Assigned To: > > > > Comments: > > > > > > > > php has no "nested function" feature like you'll find in PASCAL > > > > or in gcc if you enable the feature > > > > > > > > what happens here is that test2 is registered on execution of > > > > test in the global namespace, and when you call test a second time > > > > it cannot register test2 again > > > > > > > > (the engine shouldn't accept nested functions at all i think) > > > > > > > > Previous Comments: > > > > ------------------------------------------------------------------ > > > > --------- > > > > > > > > [2001-02-01 22:18:32] chriskl@familyhealth.com.au > > > > This script fails with: > > > > > > > > <b>Fatal error</b>: Cannot redeclare test2() in > > > > <b>-</b> on line > > > > <b>4</b><br> > > > > > > > > <?php > > > > > > > > function test() { > > > > function test2() { > > > > echo "hi"; > > > > } > > > > > > > > test2(); > > > > } > > > > > > > > test(); > > > > test(); > > > > test(); > > > > > > > > ?> > > > > > > > > ------------------------------------------------------------------ > > > > --------- > > > > > > > > > > > > Full Bug description available at: > > > > http://bugs.php.net/?id=9064 > > > > > > > > > > > > > -- > > > 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 > > > > > > > -- > > +----------------------------------------------------------------+ > > |Torben Wilson <torben@php.net> Adcore Finland| > > |http://www.coastnet.com/~torben > > http://www.adcore.com| > > |Ph: 1.604.709.0506 torben@adcore.com| > > +----------------------------------------------------------------+ > > > > -- > > 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 > > -- +----------------------------------------------------------------+ |Torben Wilson <torben@php.net> Adcore Finland| |http://www.coastnet.com/~torben http://www.adcore.com| |Ph: 1.604.709.0506 torben@adcore.com| +----------------------------------------------------------------+

« previous php.dev (#45634) next »