GAAK! a surprising (to me) little bug!

  • Thread starter Al Dunbar [MS-MVP]
  • Start date
A

Al Dunbar

Since they do not function as labels, and are not understood or processed
that way by the command processor, this seems mainly a semantic argument.
You might just as easily say that the following:

::\test\prog.exe

is either:

- a label
- a command to run an executable located on drive ":"
- a comment

Of the three possibilities, the third is the one that is most closely
related to the actual behaviour that will result.
A () construct in FOR is not a conventional block - it is more an
instance of line continuation with automatic separation of commands
... in effect, the () encloses the argument list for the function.
Actually, I can't think of any language in which it would be proper to
include a label in an argument list.
[snip]

One consideration is to ask yourself whether the avoidance of the REM
command is done for performance reasons or for aesthetic reasons?

In my case, aesthetic reasons.
If it's the former, the comments should precede the FOR loop and quote
enough of it to indicate what the remarks are about.

Probably a wise choice. In fact, I tend to try to keep for loops as simple
and short as possible, relocating the code to an internal subroutine when it
starts getting wonky.
Keeping
unnecessary stuff outside any loops will speed up the loops anyway
and is a standard optimisation tactic.

I suspect the improvement to be negligible. The entire loop is processed as
a single command, i.e. read in once and the environment variable
substitution done once. I agree that if some executable statements can be
taken out of the loop, that will have a positive impact. But worrying too
much about extraneous whitespace and comments (of either kind), is getting a
bit too ridiculous.
If it's the latter, why not just create a program named !.COM or
!.EXE that does nothing except ignore its command line parameters
and exit with no error? Then you could just use '!' as a substitute
for REM in the batch file. '!' seems more appropriate to me to
indicate a comment anyway.

Not a bad idea, certainly. But having batch files rely on non-standard
external files is just one more way to make maintenance a problem.

/Al
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top