At 04:31 AM 10/21/2002 +0200, NTPT wrote:
Hi.
I have some idea and suggestion  how to extend PHP language a bit in some
way. That may probably lead to increasing of php flexibility, allow more
modular coding to be done etc....


My sugestion is simple:
Allow  PHP programmer to explicitelly  told , WHAT variable scope will be
used  inside user defined  functions.

In the traditional approach (afaik , i use php 4.2.2 ), as is described in
the manual of php there a diferent varable scopes for each functions , only
syntax " global $valuename" ; can lead to use variables global. This aproach
is traditional and well known and is sufficient for most tasks.(I say
sufficient, not effective...). My idea is going a bit behind it.

I suggest  to introduce new keyword(s) or function(s)  into the PHP language
definiton
(i suggest syntax like  "var_scope scope" or  var_scope("scope") )

That keywords SHOULD be used in user defined  functions to  EXPLICITLY
define, WHAT kind of variable scope will be used inside this function.

scope can be either

'local' = it means, that all variables used in this function  have a local
scope only.(it means like traditional behavior of php and its variable
scopes until now )

'global' = each variable used in the function  is from global scope. Similar
to "global $variable_1,$variable_2........... $each variable used in the
main execution line of the script"

'caller' or 'inherit' This is MOST USEFUL part of the idea . Function
variable scope is the SAME as from where the function was called. (if
functino bar(),with have var_scope set to 'caller', is called from function
foo() it have the same variable scope as function foo(), almost like the
code of function bar() was included (by include "something" ) somewhere
inside foo() )
I think having something like "caller" is very bad. It would mean that functions don't have any contracts anymore as they
can start messing around with the callers symbol table.

Andi


--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to