> -----Original Message----- > From: Richard Lynch [mailto:[EMAIL PROTECTED]] > Sent: 11 July 2002 23:38 > [....] > > I apologize profusely to the fans of the "alternative syntax" > who are still > using it. > > I personally find the endxxx; to be more of an eyesore, but that's a > religious argument. :-)
Oh, yes, absolutely -- to me, braces all over the place are an eyesore, but I wouldn't argue your right to program the way you like. That's one of the plus points of PHP, it lets both of us do what we think is the beautiful thing! > >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 > > Never in my code. Glad to hear it -- nevertheless, it *is* fairly common in my experience. > If you can't tell from the logic structure of the code what } > matches what > {, you're in trouble from the get-go. :-) Well, yes. But not everyone writes that logically -- or even writes consistently-indented code! > >Another advantage to the alternative syntax is that it can > improve error > >reporting (slightly). Consider the following: > > >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!) > > Don't be ridiculous. Any decent editor will tell you where > the missing { or > } is. No need to search for it by hand. Well, yes, but not the full story. If the only clue you have is that there's probably a brace missing somewhere in the 600 lines of your file, and some of your structures nest 7 or 8 levels deep, that's still an awful lot of braces that you potentially have to check for matching partners, even with a helpful editor to ease the task. (And we know that some people don't have helpful editors -- just look at the requests in this list for recommendations!!) If, on the other hand, you get a parse error at line 234 in one of the deeper levels of nested structures, your search is immediately much more focussed. This is just a plain fact, surely...? > > Not to mention that if you've indented properly, it's trivial > to find it, > even in something as ill-suitable for Programming as NotePad. Ah, indeed -- but, again, not everyone indents properly!! > >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! > > None of my closing braces have comments. I never have a problem with > "missing" ones. You must have much keener eyesight than me, then. I often have difficulty telling which } lines up under which { (when I'm reading code written in that style, that is!), especially if they're on different pages of a listing. When I code in a braced language, I *always* comment my closing braces for this reason. Even in PHP using end* statements, I often add comment to tell me *which* "if" an "endif" matches, just to be sure. (I do the same in VB, too!) > YMMV. I guess. But I think other people's probably varies more, and the number of occasions on this list when I think "but if you'd used alternative syntax style you'd *know* where the problem was" grows by the week. Oh dear, I see I've got into rant mode once more. Right, I'll shut up now, and that really will be my last word on the topic. Well, at least until someone else brings it up again. 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