> -----Original Message----- > From: Richard Lynch [mailto:[EMAIL PROTECTED]] > Sent: 11 July 2002 10:54 > > The "alternate syntax" with the colons is passe -- I think > you'd have to dig > pretty deep to find a script old enough that uses it for > anything other than > demonstration purposes. (Rasmus?)
What utter tosh! *All* my scripts use the "alternative" syntax, as I think braces are an eyesore and an abomination, and cause more problems than they solve. I've pretty much lost count of the number of times I've seen code written like this: if (x) { while (y) { ... } // end while ... } // end if when it would be just as easy, and more functional, to write this (even saves a few characters, too!): if (x): while (y): ... endwhile; ... endif; Another advantage to the alternative syntax is that it can improve error reporting (slightly). Consider the following: if (....) { ....; while (....) { ....; for (....) { ....; .... } .... } .... PHP will tell you you have a syntax error on the very last line of your file, and you have no option but to go back and laboriously hand match all of your braces -- and with each ellipsis representing maybe tens (or even hundreds!) of lines of code and/or HTML, that's a big job. Now suppose you wrote it like this instead: if (....): ....; while (....): ....; for (....): ....; .... endwhile; .... endif; .... Now PHP will throw an error at the endwhile, because it knows there's an endfor missing -- and you've already cut out a large chunk of your code to check; better yet, as you're checking you can see at a glance what each "end" should be matching. And every "end" has to be there, too -- no cursing yourself for that lazy day when you left out a few comments on some "unimportant" closing braces! </rant> Just my two penn'orth. Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php