> > >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...?

I've never had a problem where it didn't give me a close estimate to where
the "{" or "}" was missing.  And I'm one of those ill-suited NotePad guys
(my Visual Studio copy is at work and I reformatted this computer recently).
:)

> > 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!!

I'm not sure that's a fair argument to make because you can say the same
thing about code with the if (exp): endif; code, I'm sure a lot of people
use it's simplicity (I do use it on occasion, but I indent like { }) and
then don't indent.

> > >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.

If I miss one the PHP parser gives me a big enough clue for me to find it
within 30 seconds.  I can definitely understand that though and I bet that
that is easier, especially in harder to read, uncommented code (that's a
general statement, not a shot at anyone).

> 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!)

I've got the same idea as him, but I wear glasses (not bad vision though ...
next up from 20/20).  I never added VB comments to my "End If" statements, I
might comment inside about what's going on, but never what's being matched.
I have the feeling your code is very readable, which is a good thing, but I
like my way for my own selfish reasons (much of which cannot be explained to
mere mortals!).

> > 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.

You're probably right, but it is a religious and huge experience thing.
I've been working with { } for quite, especially a while outside of PHP and
I rarely have a problem (except when moving to ASP ... that normally takes a
quick relearning curve because of the VB syntax).

> 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.

Oops.

> Cheers!
>
> Mike
>

-Chris



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to