| Deutsch English Français Italiano |
|
<uth66l$266da$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Mikko <mikko.levanto@iki.fi>
Newsgroups: comp.lang.c
Subject: Re: Block Comments Or Rest-Of-Line Comments?
Date: Thu, 21 Mar 2024 13:37:57 +0200
Organization: -
Lines: 67
Message-ID: <uth66l$266da$1@dont-email.me>
References: <utgjh0$21nsq$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="1de678d4c422bc56fa3cc2103abf2c2f";
logging-data="2300330"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/sWSwDqquHaqDJX2bFOIA4"
User-Agent: Unison/2.2
Cancel-Lock: sha1:p+pIAH++gHGRKOM/M8/WqcojRLE=
Bytes: 3062
On 2024-03-21 06:19:13 +0000, Lawrence D'Oliveiro said:
> 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?
> //
But not less than
// A very simple HTML/XML entity-escape function--why isn’t this
// part of the standard Java API?
as the empty lines do not need any comment marks.
> 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
> );
I prefer to put the argument names at the end of the line.
> Do you feel the same?
No, I use both kind of comments with languages that permit both.
--
Mikko