ID:               29104
 Comment by:       ulderico at maber dot com dot br
 Reported By:      tomas_matousek at hotmail dot com
 Status:           Open
 Bug Type:         Zend Engine 2 problem
 Operating System: *
 PHP Version:      5.0.0
 Assigned To:      Andi
 New Comment:

OH! In time! Just to reinforce the first and the second paragraph of my
last comment.

Why would you create a function that should be invoked JUST ONCE?
Initialize environment? It makes no point. You can do it directly in
the code, using "if" to distinguish any situation of environment that
one may have.


Previous Comments:
------------------------------------------------------------------------

[2004-12-30 15:16:42] ulderico at maber dot com dot br

IMHO, Nested Functions are BAD&WRONG, thus they should be disabled. 

Firstly, when you DECLARE a function inside a function, you have a
redeclaration problem. Try to execute the parent function twice and
most likely you'll receive a message: "Fatal error:  Cannot redeclare
XXXX". 

OK! Some may dispute: "let's create an undeclare_function() so as to
allow at the end of the function undeclare the child function. It would
enable to reinvoke the parent function whenever we like". Well, THIS IS
ALSO B&R. Why would you undeclare a function that you're going to use?

Secondly, if a function needs to work in a closed (encapsuled)
environment, well, I think you need a CLASS, not a function. In a class
you may have a public, private or protected variables invoked by either
public, private or protected methods.

Thusly, a code like this (sorry the indentation, I want to save
space):
class A
{ 
  function b(){}
  function c(){}
  function d(){}
  function g(){ 
    echo "function g - begin\n";
    function f(){echo "function f\n";} 
    echo "function g - end\n";
  }
}

should be written like this:
class A
{ 
  function b(){}
  function c(){}
  function d(){}
  function g(){ 
    echo "function g - begin\n";
    f::f();
    echo "function g - end\n";
  }
}
class f{
    function f(){echo "function f\n";} 
}

$obj = new A();
$obj->g();

So, the rationale is, why you need to have function within function if
you've got classes?

------------------------------------------------------------------------

[2004-08-14 01:24:12] [EMAIL PROTECTED]

While nested functions are maybe useful feature for someone declaration
of a function inside the body of a method (which happens to be a
function inside a class) is _ambigious_ . Why? There is no reserved
word "method" for marking methods of a class and "function" is used so
when it is between {} after class name "function" creates a method of
the class. IMO "function" inside a method should not be possible.

------------------------------------------------------------------------

[2004-07-16 18:00:35] postings-php-bug at hans-spath dot de

Wait a minute, PHP doesn't support nested functions?

Holy shit, documentation lies!

http://www.php.net/manual/en/language.functions.php
"Example 12-3. Functions within functions"

Do we need to file a documentation bug, too?

------------------------------------------------------------------------

[2004-07-13 21:46:59] [EMAIL PROTECTED]

PHP does not support nested functions. Still we need to disable this.

------------------------------------------------------------------------

[2004-07-13 21:42:52] tomas_matousek at hotmail dot com

PHP supports declaring functions "inline", i.e. almost anywhere in a
code. Such function is declared as global wherever it is declared.
Hence, I don't see any ambiguity if a function is declared inside a
method. PHP doesn't support adding new methods into existing class.
That's why a function declared in method can only be a global one.

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/29104

-- 
Edit this bug report at http://bugs.php.net/?id=29104&edit=1

Reply via email to