Hmmm, I don't think other programmer's sloppy coding practices are aI am going to have to strongly disagree with some of what Rob said. I agree that sloppy coding of idiots should have not impact on the design of a programming language. However I see no disadvantages to forcing you to declaring variables. Even if you are going to have loose type conversions you can still declare variables and give their intended type. If this is done the loose type conversion can be done more intelligently. It also goes a long way to documenting your code. A section at the top of a source file with a declaration of all variables and functions used makes provides an easy and consistent way to document your code. Well named functions and variables names alone, when they are all spelled out in a logical order at the top of a source file does a lot to document the code. On top of that there is a HUGE advantage to even the best programmer. Let me give you a recent example.
good argument for having to declare variables or against loose typing.
There are crappy coders in whatever language you use. The good coders
will do the right thing. If you are concerned about scripts on
hotscripts.com where the coder doesn't seem to understand the principles
of security or fully understand what is happening with their variables,
then perhaps you should be writing the code yourself or hiring someone
who does understand the language more completely. Caveat Emptor. Part of
PHPs simplicity and attractiveness is that you DON'T need to declare
variables, and you DON'T need to do manual casting. Start adding these
and you may as well be writing Java or C/C++.
lots of code;
$Key = "xyz";
lots more code here.
if($key == "xyz"){ do this stuff; } lots more code here;
I am assuming you found the error pretty quick, but when looking at the whole file and not knowing where the error is it can be very hard. There could be lots of other variable names and assignments and other logic that all could have been effecting my erroneous output. If the language forces variable deceleration you simply get an error "variable $key not defined on line x" then there is no searching no wondering, you immediately know you made a typo, and you know exactly what line it is on.
I challenge anyone to find a disadvantage in forcing decelerations of variables and functions, other than having to type more. I am sure there will be some but I am also reasonably sure I can counter all of them except the extra typing, which I have never found to be a significant factor.
Chris W
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php