This one bit me today

Richard O'Keefe ok at cs.mu.oz.au
Thu Oct 26 16:14:01 AEST 1989


In article <1989Oct25.090616.19276 at gdt.bath.ac.uk>, exspes at gdr.bath.ac.uk (P E Smee) writes:
> If contents nest, then you can comment out blocks of your code
> for various trial purposes, without having to worry about what's in the
> block you comment out.

This claim is false, as I pointed out before.  If you comment out code
containing strings containing comment delimiters, you're in trouble.
(Yes, this bit me several times.)

> I've known PL/1 programmers to avoid commenting
> their code because (since PL/1 comments don't nest) it would inhibit this
> handy testing trick.

In that case you have known some PL/I (that's a Roman I not an Arabic 1)
programmers who either were not masters of their language or who were
using an incomplete implementation.  PL/I has preprocessor facilities.
To omit a block of code in PL/I, just put
	%IF '0'B THEN %DO;
	<omitted stuff here>
	%END;
around it.

One more time:  if you have a decent editor, and you have either PL/I-style
/* */ or Pascal-style (* *) comments (but not { } comments), you can comment
out regions and bring them back again WITHOUT needing nested comments as such.
If anyone's interested, I'll post my code for it.



More information about the Comp.lang.c mailing list