Liste des Groupes | Revenir à cl c |
The original comment delimiters in C were copied from PL/I: everythingI use both - block comments when making a comment block, and line comments when adding comments to the end of a line. That seems pretty obvious to me.
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 shortI feel that "interspersed comments" are an abomination, and never use them. Opinions will vary, of course.
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.