in reply to Re^4: Need help with loop syntax errors
in thread Need help with loop syntax errors

Hi Todd!

Glad to help and I'm happy that you have all the versions working to your satisfaction.

It is obvious that I like the last version because I added it to your test code. So now comes some of my opinion as opposed to "fact"... Why did I do that?

As I commented, white space doesn't consume any CPU cycles but it can be some of the most important "code" that you write. Just imagine if there wasn't a blank line between the 4 different "test" cases? That would make the source code a lot more difficult to understand! The computer doesn't care about white space, but humans do!

In the first case, I have to read through a bunch of substitutions before I finally come to the thing that is being modified at the very end of the line! In this case, I probably want to know that $NewRev is being modified first, not last. Usually, I read the details later if I care (and maybe I don't even care). On the first read of new code, I just want to get the general picture of what is going on. There are situations where this syntax and use of the comma operator makes sense. I just don't think that this is one of those cases.

I think the next couple of versions are "ok". But I like the last version best in this particular situation. What is being modified just "jumps out". It is easy for me to glance at the three statements that do the mods to get the idea of what they do or skip over them if I don't really care at the moment. By having a line for each regex, I can put a comment there, like perhaps # backward compatible, re bug #Q45983.

I know that a "style post" like this can generate controversy. I don't want to get into an extended discussion. I do encourage you to consider the issue and form your own opinion. "Compact" code does not necessarily equate to "fast" or "clear" code.