Re: Global Variables -- why not have them?
| From: | Brian White | Date: | Mon, 09 Jul 2001 00:34:33 +0000 |
| Subject: | Re: Global Variables -- why not have them? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-56842@lists.php.net to get a copy of this message | ||
I actually like Python's approach.
* When you want to READ a variable it firstly looks in the local scope, and if it
can't find it it looks in the global scope.
* When you want to WRITE a variable, it sets it in the local scope, unless it is
explicitly said to be in the global scope.
I dislike the GLOBAL statement in that many of the bugs that get me scratching my
head are to do with when I have forgotten to use it.
On the other hand I find the Perl behaviour inherently dangerous - forgetting to
declare something as local is going to cause me big headaches one day .....
The Python appraoch gets around both of these problems quite nicely.
Regs
Brian White
At 12:59 7/07/2001 -0600, mike cullerton wrote:
there are two sets of variables. global and local. you have to assume one and specify the other. in perl, global is assumed and you have to specify local. in php, local is assumed and you have to specify global.
maybe you should be programming in perl.And maybe I don't like religious bigotry in whatever form it takes..... ------------------------- Brian White Step Two Designs Pty Ltd - SGML, XML & HTML Consultancy Phone: +612-93197901 Web: http://www.steptwo.com.au/ Email: bwhite@steptwo.com.au