Liste des Groupes | Revenir à cl c |
The original comment delimiters in C were copied from PL/I: everythingI don't have strong views about this. Block comments occasionally used to fail to match up, but with modern syntax highlighting, that is less of an issue. It's also slightly more natural to use // comments when commenting every line of a structure. The, as yiu say, if you want comments interspersed with code in the same it, it must be the old style, but it's very rare for that to be useful.
between “/*” and “*/” is a comment, even extending across multiple lines.
Pascal had something similar, only the delimiters were “{” and “}”, or
“(*” and “*)” for compatibility with machines with restricted character
sets.
For some reason, the Ada folks decided block comments were not a good
idea, and so their rule was that anything after “--” up to the end of the
line was a comment. And C++ adopted a similar rule, using “//” as their
to-end-of-line comment marker, though of course they also kept C-style
block comments. Java also keeps both these styles.
Since then, I’ve seen newer programmers gravitate towards the rest-of-line
form in preference to the block form, and I’m not sure why. I’m fond of
writing things like
/*
A very simple HTML/XML entity-escape function--why isn’t this
part of the standard Java API?
*/
which involve less typing than
//
// A very simple HTML/XML entity-escape function--why isn’t this
// part of the standard Java API?
//
Also, the “block” form allows “interspersed” comments, where a short
comment can be put in the middle of a line and followed by more program
text in the rest of the line. For example, as a way of keeping long
argument lists straight:
gdImageCopyResampled
(
/*dst =*/ ResizedFrame,
/*src =*/ Context.StillFrame,
/*dstX =*/ 0,
/*dstY =*/ 0,
/*srcX =*/ 0,
/*srcY =*/ 0,
/*dstW =*/ ResizedFrame->sx,
/*dstH =*/ ResizedFrame->sy,
/*srcW =*/ Context.StillFrame->sx,
/*srcH =*/ Context.StillFrame->sy
);
Do you feel the same?
Les messages affichés proviennent d'usenet.