Re: Block Comments Or Rest-Of-Line Comments?

Liste des GroupesRevenir à cl c  
Sujet : Re: Block Comments Or Rest-Of-Line Comments?
De : malcolm.arthur.mclean (at) *nospam* gmail.com (Malcolm McLean)
Groupes : comp.lang.c
Date : 22. Mar 2024, 23:50:22
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <utl1ve$36dgt$1@dont-email.me>
References : 1
User-Agent : Mozilla Thunderbird
On 21/03/2024 06:19, Lawrence D'Oliveiro wrote:
The original comment delimiters in C were copied from PL/I: everything
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?
I 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.
However until recently it wasn't unknown for the // comments to break. So you couldn't use them in serious, portable C programming. I think that's no longer the case.
--
Check out Basic Algorithms and my other books:
https://www.lulu.com/spotlight/bgy1mm

Date Sujet#  Auteur
21 Mar 24 * Block Comments Or Rest-Of-Line Comments?72Lawrence D'Oliveiro
21 Mar 24 +- Re: Block Comments Or Rest-Of-Line Comments?1bart
21 Mar 24 +* Re: Block Comments Or Rest-Of-Line Comments?31Mikko
21 Mar 24 i`* Re: Block Comments Or Rest-Of-Line Comments?30Lawrence D'Oliveiro
22 Mar 24 i `* Re: Block Comments Or Rest-Of-Line Comments?29David Brown
22 Mar 24 i  +- Re: Block Comments Or Rest-Of-Line Comments?1Blue-Maned_Hawk
23 Mar 24 i  +* Re: Block Comments Or Rest-Of-Line Comments?5Lawrence D'Oliveiro
23 Mar 24 i  i+* Re: Block Comments Or Rest-Of-Line Comments?2Chris M. Thomasson
23 Mar 24 i  ii`- Re: Block Comments Or Rest-Of-Line Comments?1Lawrence D'Oliveiro
23 Mar 24 i  i`* Re: Block Comments Or Rest-Of-Line Comments?2David Brown
23 Mar 24 i  i `- Re: Block Comments Or Rest-Of-Line Comments?1Malcolm McLean
2 Jul 24 i  `* Named arguments in C22Ivan Farlenkov
2 Jul 24 i   +* Re: Named arguments in C12Blue-Maned_Hawk
2 Jul 24 i   i+* Re: Named arguments in C4Richard Harnden
3 Jul 24 i   ii`* Re: Named arguments in C3Blue-Maned_Hawk
4 Jul 24 i   ii `* Re: Named arguments in C2Richard Harnden
4 Jul 24 i   ii  `- Re: Named arguments in C1Kaz Kylheku
2 Jul 24 i   i`* Re: Named arguments in C7bart
3 Jul 24 i   i +- Re: Named arguments in C1Keith Thompson
3 Jul 24 i   i +* Re: Named arguments in C4Blue-Maned_Hawk
4 Jul 24 i   i i`* Re: Named arguments in C3bart
4 Jul 24 i   i i `* Re: Named arguments in C2Keith Thompson
4 Jul 24 i   i i  `- Re: Named arguments in C1Kaz Kylheku
4 Jul 24 i   i `- Re: Named arguments in C1Opus
3 Jul 24 i   +- Re: Named arguments in C1Lawrence D'Oliveiro
4 Jul 24 i   `* Re: Named arguments in C8Bonita Montero
4 Jul 24 i    +* Re: Named arguments in C2Michael S
4 Jul 24 i    i`- Re: Named arguments in C1Michael S
4 Jul 24 i    `* Re: Named arguments in C5bart
4 Jul 24 i     `* Re: Named arguments in C4Bonita Montero
4 Jul 24 i      +- Re: Named arguments in C1Bonita Montero
4 Jul 24 i      `* Re: Named arguments in C2bart
4 Jul 24 i       `- Re: Named arguments in C1Bonita Montero
21 Mar 24 +- Re: Block Comments Or Rest-Of-Line Comments?1Blue-Maned_Hawk
21 Mar 24 +* Re: Block Comments Or Rest-Of-Line Comments?4Tim Rentsch
21 Mar 24 i`* Re: Block Comments Or Rest-Of-Line Comments?3Dan Cross
22 Mar 24 i `* Re: Block Comments Or Rest-Of-Line Comments?2Tim Rentsch
23 Mar 24 i  `- Re: Block Comments Or Rest-Of-Line Comments?1Dan Cross
21 Mar 24 +* Re: Block Comments Or Rest-Of-Line Comments?16David Brown
21 Mar 24 i`* Re: Block Comments Or Rest-Of-Line Comments?15Richard Harnden
21 Mar 24 i +* Re: Block Comments Or Rest-Of-Line Comments?13Keith Thompson
21 Mar 24 i i+* Re: Block Comments Or Rest-Of-Line Comments?5Richard Harnden
21 Mar 24 i ii`* Re: Block Comments Or Rest-Of-Line Comments?4Keith Thompson
21 Mar 24 i ii +- Re: Block Comments Or Rest-Of-Line Comments?1Richard Harnden
21 Mar 24 i ii `* Re: Block Comments Or Rest-Of-Line Comments?2Lawrence D'Oliveiro
22 Mar 24 i ii  `- Re: Block Comments Or Rest-Of-Line Comments?1Keith Thompson
21 Mar 24 i i+* Re: Block Comments Or Rest-Of-Line Comments?2Kaz Kylheku
22 Mar 24 i ii`- Re: Block Comments Or Rest-Of-Line Comments?1Keith Thompson
21 Mar 24 i i+* Re: Block Comments Or Rest-Of-Line Comments?2Kaz Kylheku
27 Apr 24 i ii`- Re: Block Comments Or Rest-Of-Line Comments?1paul
22 Mar 24 i i`* Re: Block Comments Or Rest-Of-Line Comments?3James Kuyper
22 Mar 24 i i +- Re: Block Comments Or Rest-Of-Line Comments?1Keith Thompson
23 Mar 24 i i `- Re: Block Comments Or Rest-Of-Line Comments?1Lawrence D'Oliveiro
22 Mar 24 i `- Re: Block Comments Or Rest-Of-Line Comments?1David Brown
21 Mar 24 +* Re: Block Comments Or Rest-Of-Line Comments?2fir
21 Mar 24 i`- Re: Block Comments Or Rest-Of-Line Comments?1Lawrence D'Oliveiro
23 Mar 24 +- Re: Block Comments Or Rest-Of-Line Comments?1Malcolm McLean
23 Apr 24 +* Re: Block Comments Or Rest-Of-Line Comments?9DFS
24 Apr 24 i+- Re: Block Comments Or Rest-Of-Line Comments?1Lawrence D'Oliveiro
24 Apr 24 i`* Re: Block Comments Or Rest-Of-Line Comments?7Blue-Maned_Hawk
24 Apr 24 i +* Re: Block Comments Or Rest-Of-Line Comments?2Sjouke Burry
25 Apr 24 i i`- Re: Block Comments Or Rest-Of-Line Comments?1Blue-Maned_Hawk
25 Apr 24 i `* Re: Block Comments Or Rest-Of-Line Comments?4DFS
26 Apr 24 i  `* Re: Block Comments Or Rest-Of-Line Comments?3Blue-Maned_Hawk
26 Apr 24 i   +- Re: Block Comments Or Rest-Of-Line Comments?1Chris M. Thomasson
26 Apr 24 i   `- Re: Block Comments Or Rest-Of-Line Comments?1DFS
23 Apr 24 +* Re: Block Comments Or Rest-Of-Line Comments?5Kaz Kylheku
24 Apr 24 i`* Re: Block Comments Or Rest-Of-Line Comments?4Lowell Gilbert
24 Apr 24 i +* Re: Block Comments Or Rest-Of-Line Comments?2Ben Bacarisse
24 Apr 24 i i`- Re: Block Comments Or Rest-Of-Line Comments?1Lowell Gilbert
24 Apr 24 i `- Re: Block Comments Or Rest-Of-Line Comments?1Kaz Kylheku
27 Apr 24 `- Re: Block Comments Or Rest-Of-Line Comments?1paul

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal