Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"Atomic batteries to power, turbines to speed." -- Robin, The Boy Wonder


devel / comp.lang.c / Block Comments Or Rest-Of-Line Comments?

SubjectAuthor
* Block Comments Or Rest-Of-Line Comments?Lawrence D'Oliveiro
+- Re: Block Comments Or Rest-Of-Line Comments?bart
+* Re: Block Comments Or Rest-Of-Line Comments?Mikko
|`* Re: Block Comments Or Rest-Of-Line Comments?Lawrence D'Oliveiro
| `* Re: Block Comments Or Rest-Of-Line Comments?David Brown
|  +- Re: Block Comments Or Rest-Of-Line Comments?Blue-Maned_Hawk
|  `* Re: Block Comments Or Rest-Of-Line Comments?Lawrence D'Oliveiro
|   +* Re: Block Comments Or Rest-Of-Line Comments?Chris M. Thomasson
|   |`- Re: Block Comments Or Rest-Of-Line Comments?Lawrence D'Oliveiro
|   `* Re: Block Comments Or Rest-Of-Line Comments?David Brown
|    `- Re: Block Comments Or Rest-Of-Line Comments?Malcolm McLean
+* Re: Block Comments Or Rest-Of-Line Comments?Scott Lurndal
|`* Re: Block Comments Or Rest-Of-Line Comments?Tim Rentsch
| `* Re: Block Comments Or Rest-Of-Line Comments?Dan Cross
|  `* Re: Block Comments Or Rest-Of-Line Comments?Tim Rentsch
|   `- Re: Block Comments Or Rest-Of-Line Comments?Dan Cross
+- Re: Block Comments Or Rest-Of-Line Comments?Blue-Maned_Hawk
+* Re: Block Comments Or Rest-Of-Line Comments?David Brown
|`* Re: Block Comments Or Rest-Of-Line Comments?Richard Harnden
| +* Re: Block Comments Or Rest-Of-Line Comments?Keith Thompson
| |+* Re: Block Comments Or Rest-Of-Line Comments?Richard Harnden
| ||`* Re: Block Comments Or Rest-Of-Line Comments?Keith Thompson
| || +- Re: Block Comments Or Rest-Of-Line Comments?Richard Harnden
| || `* Re: Block Comments Or Rest-Of-Line Comments?Lawrence D'Oliveiro
| ||  `- Re: Block Comments Or Rest-Of-Line Comments?Keith Thompson
| |+* Re: Block Comments Or Rest-Of-Line Comments?Scott Lurndal
| ||`* Re: Block Comments Or Rest-Of-Line Comments?Kaz Kylheku
| || `- Re: Block Comments Or Rest-Of-Line Comments?paul
| |+* Re: Block Comments Or Rest-Of-Line Comments?Kaz Kylheku
| ||`- Re: Block Comments Or Rest-Of-Line Comments?Keith Thompson
| |`* Re: Block Comments Or Rest-Of-Line Comments?James Kuyper
| | +- Re: Block Comments Or Rest-Of-Line Comments?Keith Thompson
| | `- Re: Block Comments Or Rest-Of-Line Comments?Lawrence D'Oliveiro
| `- Re: Block Comments Or Rest-Of-Line Comments?David Brown
+* Re: Block Comments Or Rest-Of-Line Comments?fir
|`- Re: Block Comments Or Rest-Of-Line Comments?Lawrence D'Oliveiro
+- Re: Block Comments Or Rest-Of-Line Comments?Malcolm McLean
+* Re: Block Comments Or Rest-Of-Line Comments?DFS
|+- Re: Block Comments Or Rest-Of-Line Comments?Lawrence D'Oliveiro
|`* Re: Block Comments Or Rest-Of-Line Comments?Blue-Maned_Hawk
| +* Re: Block Comments Or Rest-Of-Line Comments?Sjouke Burry
| |`- Re: Block Comments Or Rest-Of-Line Comments?Blue-Maned_Hawk
| `* Re: Block Comments Or Rest-Of-Line Comments?DFS
|  `* Re: Block Comments Or Rest-Of-Line Comments?Blue-Maned_Hawk
|   +- Re: Block Comments Or Rest-Of-Line Comments?Chris M. Thomasson
|   `- Re: Block Comments Or Rest-Of-Line Comments?DFS
+* Re: Block Comments Or Rest-Of-Line Comments?Kaz Kylheku
|`* Re: Block Comments Or Rest-Of-Line Comments?Lowell Gilbert
| +* Re: Block Comments Or Rest-Of-Line Comments?Ben Bacarisse
| |`- Re: Block Comments Or Rest-Of-Line Comments?Lowell Gilbert
| `- Re: Block Comments Or Rest-Of-Line Comments?Kaz Kylheku
`- Re: Block Comments Or Rest-Of-Line Comments?paul

Pages:123
Block Comments Or Rest-Of-Line Comments?

<utgjh0$21nsq$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34585&group=comp.lang.c#34585

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo...@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.lang.c
Subject: Block Comments Or Rest-Of-Line Comments?
Date: Thu, 21 Mar 2024 06:19:13 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 48
Message-ID: <utgjh0$21nsq$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 21 Mar 2024 06:19:13 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="badb6633f042ee08dd03f65d8f49603e";
logging-data="2154394"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/n2DEFL7jE6WZhykg0tt76"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:PA2ZP41uA+sLABusxyaCvqDNMSE=
 by: Lawrence D'Oliv - Thu, 21 Mar 2024 06:19 UTC

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?

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

<utgv9b$24isf$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34588&group=comp.lang.c#34588

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (bart)
Newsgroups: comp.lang.c
Subject: Re: Block Comments Or Rest-Of-Line Comments?
Date: Thu, 21 Mar 2024 09:39:54 +0000
Organization: A noiseless patient Spider
Lines: 116
Message-ID: <utgv9b$24isf$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-Date: Thu, 21 Mar 2024 09:39:55 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="a72988462ea30744df8fa7c632b05f91";
logging-data="2247567"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Q8lhi8pNN4usR7MP/7Kqy"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:UZytr2Qjbx5ya/iancKTwoHezhU=
Content-Language: en-GB
In-Reply-To: <utgjh0$21nsq$2@dont-email.me>
 by: bart - Thu, 21 Mar 2024 09:39 UTC

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?

No. I can't remember the last time I used /*...*/ comments in C. They're
usually more fiddly to type, and don't nest properly, so that here, if
if you forget */ or don't get it right:

one; /* c1
two; /* c2 */
three; /* c3 */

you get more commented out than you expected.

Relying on possible syntax highlighting of some tools doesn't fix it; it
wouldn't have existed for the first few decades of the language, and my
own editor doesn't do so.

(It does detect // comments which are far easier to support since it
only has to look at the current line; it doesn't need to remember
whether there was an opening /* 5,887 lines previously.)

I see also that 'type' and 'cat' shell commands don't highlight either.

Besides, if you put too much reliance on the editor, then with this example:

> which involve less typing than
>
> //
> // A very simple HTML/XML entity-escape function--why isn’t this
> // part of the standard Java API?
> //

my editor can comment this out this block by pressing the same <insert
line comment> key four times, less typing than using /* */ which can
involve inserting extra lines (which may affect line numbers if that is
important).

If I have a piece of code like this:

s1;
// s2a;
s2b;
s3;

And I need to temporarily comment out the whole block like so:

// s1;
//// s2a;
// s2b;
// s3;

I can do so easily. You can't do that using only /* comments:

s1;
/* s2a; */
s2b;
s3;

because they don't nest.

In short, I no longer bother with block comments in a language; I regard
them as an editor function.

Yes, intra-line comments are sometimes useful, and I have played around
with syntax ideas just for those, for example:

one, \two,\ three

here the 'two,' is commented out. But it just doesn't come up often enough.

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

<uth66l$266da$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34589&group=comp.lang.c#34589

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: mikko.le...@iki.fi (Mikko)
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=
 by: Mikko - Thu, 21 Mar 2024 11:37 UTC

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

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

<_iXKN.556576$PuZ9.147822@fx11.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34593&group=comp.lang.c#34593

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx11.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Block Comments Or Rest-Of-Line Comments?
Newsgroups: comp.lang.c
References: <utgjh0$21nsq$2@dont-email.me>
Lines: 9
Message-ID: <_iXKN.556576$PuZ9.147822@fx11.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Thu, 21 Mar 2024 14:16:26 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Thu, 21 Mar 2024 14:16:26 GMT
X-Received-Bytes: 781
 by: Scott Lurndal - Thu, 21 Mar 2024 14:16 UTC

Lawrence D'Oliveiro <ldo@nz.invalid> writes:
>The original comment delimiters in C were copied from PL/I: everything

Cite?

The answer to the question in the Subject: header is, wait for it,

Both.

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

<pan$ef334$df112a83$45953aa0$2a919288@invalid.invalid>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34594&group=comp.lang.c#34594

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!bluemanedhawk.eternal-september.org!.POSTED!not-for-mail
From: bluemane...@invalid.invalid (Blue-Maned_Hawk)
Newsgroups: comp.lang.c
Subject: Re: Block Comments Or Rest-Of-Line Comments?
Date: Thu, 21 Mar 2024 14:19:24 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <pan$ef334$df112a83$45953aa0$2a919288@invalid.invalid>
References: <utgjh0$21nsq$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 21 Mar 2024 14:19:24 -0000 (UTC)
Injection-Info: bluemanedhawk.eternal-september.org; posting-host="1dda6d154be82ef21dec3bcea01b62b2";
logging-data="2375668"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18XCjC7YXW7jSlqr8c6hCeeXwaUvUX0vhc="
User-Agent: Pan/0.154 (Izium; 517acf4)
Cancel-Lock: sha1:Wub6Tu9Pq9j2tIiiPCevmn+aBCg=
X-Face: Taumatawhakatangihangakoauauotamateaturipukakapikimaungahoronuku
pokaiwhenuakitanatahu
Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAIAAADYYG7QAAACh0lEQVRYw71Z21bD
MAzzevbfkr4cHjrSXJyL044+MDa6WLEl2SkvkrZ1AbAvXO+bUGSCPYnsuIVGMpm
ZLnjX718GhAKNsp8lON2F9VrhELwIgJlBepkZjA78rVK+FkmNhEJK76UsJlz8+E
rJsjrpYouhLo/SC6qPHgakFOR8wV9+8rCfO/I/oVnmUZUp42/LW2XkLj9TCFNM9
jp5g2EmHZgpYZjCOkYU7sXVogRylJqpdggoFLG1g09Flah/7kErCxzR9HgXPYsq
0glb9cxjIz2Vsk9AmAoCSxECpD713joMKjQqLAtmMqJmXjdVvlMnMQCVITotJd1
z+fh1f1NNo+vuc1KnhWUmY7t03vydTud9BbXCtN3L2PL3bK7JCNG0GHzuZxafyB
fxevCxpm1vrwZltqw6SILCcdoCE6PGQC8wZWDA9Or7Qp5s3lAZezys0nDazs9S9
R0TjwEiksRxLkNPC1NMMWPs1bj0Ei0Yuo+JVtFLuzP1NRJ16qXWN8DhhtmS4PDg
O6mqRxs4bEJrYt087mSIow/1VzW2oFlMQuiuIy/KsUagvhdw6hSjJGlIavbLF8x
j3X47bccLcUSi0dkWh1nUZNhANT1tHKUXrNxNLbd9KPb9wDDVrKwmPQMOPQ1oy6
k5I1DwzDeRJd3jVIhDAUxq3ngzJG4CCkNXZxZVMcjefoK2J0gUY2S3rxz/RuTFx
2zHd9U+obimJXMG4edsk/2j5pTU5G1MmzbRLxkfq5EiT1GGsidvMGzi+1goGb2l
GCrN+nGnV8xj3q3JLRDVPL96vUc7Z4aJ3TN1mVqWAMJMfG+Jxh6TQqP+92iZkCU
xtglds1AB6r0aiSHKcnFck+p/c/0CbacFLQcajGcAAAAASUVORK5CYII=
 by: Blue-Maned_Hawk - Thu, 21 Mar 2024 14:19 UTC

When writing C, i use block comments because they're more flexible, and
_only_ block comments for the sake of “picking one and sticking with it”.
The one exception is that i use #if 0 … #endif blocks to “comment out”
blocks of code, since those nest.

--
Blue-Maned_Hawk│shortens to Hawk│/blu.mɛin.dʰak/│he/him/his/himself/Mr.
blue-maned_hawk.srht.site
The flesh is rotten, but the booze is holding out.

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

<86r0g3liii.fsf@linuxsc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34596&group=comp.lang.c#34596

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: Block Comments Or Rest-Of-Line Comments?
Date: Thu, 21 Mar 2024 08:19:33 -0700
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <86r0g3liii.fsf@linuxsc.com>
References: <utgjh0$21nsq$2@dont-email.me> <_iXKN.556576$PuZ9.147822@fx11.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="0bd4e75010dfbc7f5eb72cff193a6122";
logging-data="2399943"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18xnj3UvMfj2dLz1/dbReEOHvIo0EweGWU="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:7AP4vZshPs59Jrj2yBn/+fbzoKM=
sha1:T1BdbkwMOhZErC2ej63Wj6bwXz4=
 by: Tim Rentsch - Thu, 21 Mar 2024 15:19 UTC

scott@slp53.sl.home (Scott Lurndal) writes:

> Lawrence D'Oliveiro <ldo@nz.invalid> writes:
>
>> The original comment delimiters in C were copied from PL/I: everything
>
> Cite?

Seen in the B language manual:

Comments are delimited as in PL/I by /* and */.

https://www.bell-labs.com/usr/dmr/www/kbman.html

Note that this style of commenting was not present in
B's precursor language, BCPL.

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

<uthj7e$29aoc$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34597&group=comp.lang.c#34597

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: Block Comments Or Rest-Of-Line Comments?
Date: Thu, 21 Mar 2024 16:20:13 +0100
Organization: A noiseless patient Spider
Lines: 65
Message-ID: <uthj7e$29aoc$2@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-Date: Thu, 21 Mar 2024 15:20:14 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="9083fc13632a11f6b0fc246dd1fa196c";
logging-data="2403084"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18zT7IoDWSvUd8IJVr/4ze9CWpCu9/kWbM="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:RBbvHNjobV2boMPHZCapQ7LcKJ4=
Content-Language: en-GB
In-Reply-To: <utgjh0$21nsq$2@dont-email.me>
 by: David Brown - Thu, 21 Mar 2024 15:20 UTC

On 21/03/2024 07: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?
> //
>

I 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.

(Many IDEs will format block comments in a variety of styles according
to user preference - the number of characters typed is rarely an issue.)

> 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 feel that "interspersed comments" are an abomination, and never use
them. Opinions will vary, of course.

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

<uthne5$2ad1b$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34598&group=comp.lang.c#34598

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: richard....@gmail.invalid (Richard Harnden)
Newsgroups: comp.lang.c
Subject: Re: Block Comments Or Rest-Of-Line Comments?
Date: Thu, 21 Mar 2024 16:32:05 +0000
Organization: A noiseless patient Spider
Lines: 46
Message-ID: <uthne5$2ad1b$1@dont-email.me>
References: <utgjh0$21nsq$2@dont-email.me> <uthj7e$29aoc$2@dont-email.me>
Reply-To: richard.harnden@invalid.com
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 21 Mar 2024 16:32:05 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="3635f5b374276661f74384269e5078d3";
logging-data="2438187"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+cH7DbB367Ku4WmFMfvLt5nYPb29X0jbk="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:uRjezwETxrhs08Bp6NKbH8aUxC8=
Content-Language: en-GB
In-Reply-To: <uthj7e$29aoc$2@dont-email.me>
 by: Richard Harnden - Thu, 21 Mar 2024 16:32 UTC

On 21/03/2024 15:20, David Brown wrote:
> On 21/03/2024 07: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?
>> //
>>
>
> I 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.

And sometimes, when it's not a really a comment, but rather a block of
code I don't want right now:

#ifdef 0
....
#endif

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

<uthsgp$94j$1@reader1.panix.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34602&group=comp.lang.c#34602

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.spitfire.i.gajendra.net!not-for-mail
From: cro...@spitfire.i.gajendra.net (Dan Cross)
Newsgroups: comp.lang.c
Subject: Re: Block Comments Or Rest-Of-Line Comments?
Date: Thu, 21 Mar 2024 17:58:49 -0000 (UTC)
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <uthsgp$94j$1@reader1.panix.com>
References: <utgjh0$21nsq$2@dont-email.me> <_iXKN.556576$PuZ9.147822@fx11.iad> <86r0g3liii.fsf@linuxsc.com>
Injection-Date: Thu, 21 Mar 2024 17:58:49 -0000 (UTC)
Injection-Info: reader1.panix.com; posting-host="spitfire.i.gajendra.net:166.84.136.80";
logging-data="9363"; mail-complaints-to="abuse@panix.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: cross@spitfire.i.gajendra.net (Dan Cross)
 by: Dan Cross - Thu, 21 Mar 2024 17:58 UTC

In article <86r0g3liii.fsf@linuxsc.com>,
Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:
>scott@slp53.sl.home (Scott Lurndal) writes:
>
>> Lawrence D'Oliveiro <ldo@nz.invalid> writes:
>>
>>> The original comment delimiters in C were copied from PL/I: everything
>>
>> Cite?
>
>Seen in the B language manual:
>
> Comments are delimited as in PL/I by /* and */.
>
>https://www.bell-labs.com/usr/dmr/www/kbman.html
>
>Note that this style of commenting was not present in
>B's precursor language, BCPL.

It would be appropriate to qualify this statement with some kind
of timeframe as BCPL is still used (albeit not widely, I
assume).

The current version of the language includes `/* ... */` comments
as one of two supported forms:
https://www.cl.cam.ac.uk/~mr10/bcplman.pdf

It appears that this was also present in the 1979 version
described in, "BCPL the language and its compiler" by Martin
Richards:
https://ia803107.us.archive.org/16/items/richards1979bcpl/richards1979bcpl.pdf;
see in particular the lexical analyzer fragment starting on line
127 of page 87.

However, I believe this was not the case at the time that B was
defined. At least, it is not in the BCPL definition just a
couple of years earlier, despite several years of experience
with PL/1 by then:
https://www.bell-labs.com/usr/dmr/www/bcpl.pdf
Indeed, Dennis Ritchie suggested that some changes to BCPL were
influences taken from C:
https://www.bell-labs.com/usr/dmr/www/bcpl.html

Certainly, both Multics and CTSS BCPL only understand `// ...`,
and those are likely the compilers that Ken Thompson would have
been most familiar with at the time B was created. E.g.:
https://github.com/dancrossnyc/multics/blob/main/library_dir_dir/system_library_tools/source/bound_bcpl_.s.archive/bcpl_lex1.bcpl#L90

Regarding the original claim, despite OP being a known troll, it
appears to be true. Dennis Ritchie also mentioned it in his C
history paper: https://www.bell-labs.com/usr/dmr/www/chist.html

As far as I know, PL/I was the first language to use `/*` and
`*/` as comment delimeters.

- Dan C.

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

<uthva5$2k4da$1@i2pn2.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34604&group=comp.lang.c#34604

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!.POSTED!not-for-mail
From: fir...@grunge.pl (fir)
Newsgroups: comp.lang.c
Subject: Re: Block Comments Or Rest-Of-Line Comments?
Date: Thu, 21 Mar 2024 19:46:29 +0100
Organization: i2pn2 (i2pn.org)
Message-ID: <uthva5$2k4da$1@i2pn2.org>
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-Date: Thu, 21 Mar 2024 18:46:29 -0000 (UTC)
Injection-Info: i2pn2.org;
logging-data="2757034"; mail-complaints-to="usenet@i2pn2.org";
posting-account="+ydHcGjgSeBt3Wz3WTfKefUptpAWaXduqfw5xdfsuS0";
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:27.0) Gecko/20100101 Firefox/27.0 SeaMonkey/2.24
X-Spam-Checker-Version: SpamAssassin 4.0.0
In-Reply-To: <utgjh0$21nsq$2@dont-email.me>
 by: fir - Thu, 21 Mar 2024 18:46 UTC

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?
>

in practice i fint /* */ comments not handy - as bartc noted there is
clear bug thah they dont nest and this is specifically annoying

"i consider this type of comments personally";

the advantage of this above is they are kinda basic i mean c using them
and not using the other type is "thinner", they also felt liek more
physical - and eventually could be build in binary imo by some compiler
switch

i never seen anybody who ises it though, and i noticed that i can use it
but not yet decided - mostly i use // coments becouse i nearly
exclusively use comments to comment out code and in editor i got it
under control+shift+c

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

<87msqr1j8x.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34605&group=comp.lang.c#34605

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: Block Comments Or Rest-Of-Line Comments?
Date: Thu, 21 Mar 2024 12:23:58 -0700
Organization: None to speak of
Lines: 22
Message-ID: <87msqr1j8x.fsf@nosuchdomain.example.com>
References: <utgjh0$21nsq$2@dont-email.me> <uthj7e$29aoc$2@dont-email.me>
<uthne5$2ad1b$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="0bf58c5e3e50115de10475b5e7b86fc1";
logging-data="2510880"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18xwZxBIiIc2lQ+9brnF2H3"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:3qIV9sQTk6DEWs2NYCmqdgTNAbo=
sha1:lPJGw+Pj4eKvMKCMsqDMuPE/QRU=
 by: Keith Thompson - Thu, 21 Mar 2024 19:23 UTC

Richard Harnden <richard.nospam@gmail.invalid> writes:
[...]
> And sometimes, when it's not a really a comment, but rather a block of
> code I don't want right now:
>
> #ifdef 0
> ...
> #endif

I think you mean "#if 0".

I use that sometimes, but one disadvantage is that if you're viewing the
middle of a very large block of code, it can be hard to tell that it's
been "commented" out.

I have a script that applies "#if 0" and "#endif" to a block of code
*and* prepends "* " to each line in the block.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Medtronic
void Void(void) { Void(); } /* The recursive call of the void */

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

<uti2gj$2d5i5$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34607&group=comp.lang.c#34607

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: richard....@gmail.invalid (Richard Harnden)
Newsgroups: comp.lang.c
Subject: Re: Block Comments Or Rest-Of-Line Comments?
Date: Thu, 21 Mar 2024 19:41:07 +0000
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <uti2gj$2d5i5$1@dont-email.me>
References: <utgjh0$21nsq$2@dont-email.me> <uthj7e$29aoc$2@dont-email.me>
<uthne5$2ad1b$1@dont-email.me> <87msqr1j8x.fsf@nosuchdomain.example.com>
Reply-To: richard.harnden@invalid.com
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 21 Mar 2024 19:41:07 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="0d45912f7edf2970cf814add7ea10bc5";
logging-data="2528837"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Z04ad0pxr0UM9SNoVmfy7oNDRgAZSRMc="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:BHWAFCok7tp7cTrMghVxX50Z4Cg=
In-Reply-To: <87msqr1j8x.fsf@nosuchdomain.example.com>
Content-Language: en-GB
 by: Richard Harnden - Thu, 21 Mar 2024 19:41 UTC

On 21/03/2024 19:23, Keith Thompson wrote:
> Richard Harnden <richard.nospam@gmail.invalid> writes:
> [...]
>> And sometimes, when it's not a really a comment, but rather a block of
>> code I don't want right now:
>>
>> #ifdef 0
>> ...
>> #endif
>
> I think you mean "#if 0".

Yes I did :)

>
> I use that sometimes, but one disadvantage is that if you're viewing the
> middle of a very large block of code, it can be hard to tell that it's
> been "commented" out.
>
> I have a script that applies "#if 0" and "#endif" to a block of code
> *and* prepends "* " to each line in the block.
>

That's a good ideo. Can you share it?

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

<87edc31i3e.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34609&group=comp.lang.c#34609

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: Block Comments Or Rest-Of-Line Comments?
Date: Thu, 21 Mar 2024 12:48:53 -0700
Organization: None to speak of
Lines: 65
Message-ID: <87edc31i3e.fsf@nosuchdomain.example.com>
References: <utgjh0$21nsq$2@dont-email.me> <uthj7e$29aoc$2@dont-email.me>
<uthne5$2ad1b$1@dont-email.me>
<87msqr1j8x.fsf@nosuchdomain.example.com>
<uti2gj$2d5i5$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="0bf58c5e3e50115de10475b5e7b86fc1";
logging-data="2532317"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18oc0Pau8x1jkkdT9rpHFre"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:gvyWLrroMgAzmyjh8FjVuy/KB6g=
sha1:0beu3Ns2jEqFyBadOt+iMzPqlRA=
 by: Keith Thompson - Thu, 21 Mar 2024 19:48 UTC

Richard Harnden <richard.nospam@gmail.invalid> writes:
> On 21/03/2024 19:23, Keith Thompson wrote:
>> Richard Harnden <richard.nospam@gmail.invalid> writes:
>> [...]
>>> And sometimes, when it's not a really a comment, but rather a block of
>>> code I don't want right now:
>>>
>>> #ifdef 0
>>> ...
>>> #endif
>> I think you mean "#if 0".
>
> Yes I did :)
>
>> I use that sometimes, but one disadvantage is that if you're viewing
>> the
>> middle of a very large block of code, it can be hard to tell that it's
>> been "commented" out.
>> I have a script that applies "#if 0" and "#endif" to a block of code
>> *and* prepends "* " to each line in the block.
>
> That's a good ideo. Can you share it?

Sure. It's a Perl script called "if0". It tries to deal with
variations in line endings (I sometimes work with code with LF and/or
CRLF line endings) and with tabs vs. spaces as indentation.

I don't have a script that undoes what if0 does. I might write one
one of these days, but usually I can just revert the change in source
control or change it back manually.

Complaints about Perl being write-only will be cheerfully ignored.

```
#!/usr/bin/perl

use strict;
use warnings;

my @lines = <>;
my $newline = "\n";
if (defined $lines[0] and $lines[0] =~ /\r$/) {
$newline = "\r\n";
}

print "#if 0$newline";
foreach my $line (@lines) {
if ($line =~ /^ /) {
$line =~ s/ /*/;
}
elsif ($line =~ /^\r?$/) {
$line =~ s/^/*/;
}
else {
$line =~ s/^/* /;
}
print $line;
} print "#endif /* 0 */$newline";
```

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Medtronic
void Void(void) { Void(); } /* The recursive call of the void */

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

<uti38o$2db80$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34610&group=comp.lang.c#34610

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: richard....@gmail.invalid (Richard Harnden)
Newsgroups: comp.lang.c
Subject: Re: Block Comments Or Rest-Of-Line Comments?
Date: Thu, 21 Mar 2024 19:54:00 +0000
Organization: A noiseless patient Spider
Lines: 65
Message-ID: <uti38o$2db80$1@dont-email.me>
References: <utgjh0$21nsq$2@dont-email.me> <uthj7e$29aoc$2@dont-email.me>
<uthne5$2ad1b$1@dont-email.me> <87msqr1j8x.fsf@nosuchdomain.example.com>
<uti2gj$2d5i5$1@dont-email.me> <87edc31i3e.fsf@nosuchdomain.example.com>
Reply-To: richard.harnden@invalid.com
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 21 Mar 2024 19:54:00 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="0d45912f7edf2970cf814add7ea10bc5";
logging-data="2534656"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ndsG0xI+Jan/WQYJBncRbKzgL3PZGesA="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:Iqq0Ftn6tiCrbZhXxIguktnZiWE=
In-Reply-To: <87edc31i3e.fsf@nosuchdomain.example.com>
Content-Language: en-GB
 by: Richard Harnden - Thu, 21 Mar 2024 19:54 UTC

On 21/03/2024 19:48, Keith Thompson wrote:
> Richard Harnden <richard.nospam@gmail.invalid> writes:
>> On 21/03/2024 19:23, Keith Thompson wrote:
>>> Richard Harnden <richard.nospam@gmail.invalid> writes:
>>> [...]
>>>> And sometimes, when it's not a really a comment, but rather a block of
>>>> code I don't want right now:
>>>>
>>>> #ifdef 0
>>>> ...
>>>> #endif
>>> I think you mean "#if 0".
>>
>> Yes I did :)
>>
>>> I use that sometimes, but one disadvantage is that if you're viewing
>>> the
>>> middle of a very large block of code, it can be hard to tell that it's
>>> been "commented" out.
>>> I have a script that applies "#if 0" and "#endif" to a block of code
>>> *and* prepends "* " to each line in the block.
>>
>> That's a good ideo. Can you share it?
>
> Sure. It's a Perl script called "if0". It tries to deal with
> variations in line endings (I sometimes work with code with LF and/or
> CRLF line endings) and with tabs vs. spaces as indentation.
>
> I don't have a script that undoes what if0 does. I might write one
> one of these days, but usually I can just revert the change in source
> control or change it back manually.
>
> Complaints about Perl being write-only will be cheerfully ignored.
>
> ```
> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
> my @lines = <>;
> my $newline = "\n";
> if (defined $lines[0] and $lines[0] =~ /\r$/) {
> $newline = "\r\n";
> }
>
> print "#if 0$newline";
> foreach my $line (@lines) {
> if ($line =~ /^ /) {
> $line =~ s/ /*/;
> }
> elsif ($line =~ /^\r?$/) {
> $line =~ s/^/*/;
> }
> else {
> $line =~ s/^/* /;
> }
> print $line;
> }
> print "#endif /* 0 */$newline";
> ```
>

Thank you

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

<5D0LN.84949$_a1e.79924@fx16.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34611&group=comp.lang.c#34611

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx16.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Block Comments Or Rest-Of-Line Comments?
Newsgroups: comp.lang.c
References: <utgjh0$21nsq$2@dont-email.me> <uthj7e$29aoc$2@dont-email.me> <uthne5$2ad1b$1@dont-email.me> <87msqr1j8x.fsf@nosuchdomain.example.com>
Lines: 26
Message-ID: <5D0LN.84949$_a1e.79924@fx16.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Thu, 21 Mar 2024 20:19:13 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Thu, 21 Mar 2024 20:19:13 GMT
X-Received-Bytes: 1525
 by: Scott Lurndal - Thu, 21 Mar 2024 20:19 UTC

Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>Richard Harnden <richard.nospam@gmail.invalid> writes:
>[...]
>> And sometimes, when it's not a really a comment, but rather a block of
>> code I don't want right now:
>>
>> #ifdef 0
>> ...
>> #endif
>
>I think you mean "#if 0".
>
>I use that sometimes, but one disadvantage is that if you're viewing the
>middle of a very large block of code, it can be hard to tell that it's
>been "commented" out.

Often syntax highlighting (e.g. vim) will solve that.

In projects with many fingers in the pie, I generally prefer either a
descriptive (and undefined) macro name or a block comment in
the #if 0 region to indicate exactly _why_ it was not just removed
from the source file entirely.

Makes it easier for whomever is reading and/or maintaining the
code to follow it.

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

<20240321132129.448@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34614&group=comp.lang.c#34614

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 433-929-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: Block Comments Or Rest-Of-Line Comments?
Date: Thu, 21 Mar 2024 20:22:48 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <20240321132129.448@kylheku.com>
References: <utgjh0$21nsq$2@dont-email.me> <uthj7e$29aoc$2@dont-email.me>
<uthne5$2ad1b$1@dont-email.me> <87msqr1j8x.fsf@nosuchdomain.example.com>
Injection-Date: Thu, 21 Mar 2024 20:22:48 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="8a88f4f3d1bb162453330ac9f4d394b5";
logging-data="2546182"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+obDUiZnt1ZOK7DIWXwv+/r18LPSxgU7Q="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:0MNWRIIicEYA7TWVkELFEHciMRY=
 by: Kaz Kylheku - Thu, 21 Mar 2024 20:22 UTC

On 2024-03-21, Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
> Richard Harnden <richard.nospam@gmail.invalid> writes:
> [...]
>> And sometimes, when it's not a really a comment, but rather a block of
>> code I don't want right now:
>>
>> #ifdef 0
>> ...
>> #endif
>
> I think you mean "#if 0".
>
> I use that sometimes, but one disadvantage is that if you're viewing the
> middle of a very large block of code, it can be hard to tell that it's
> been "commented" out.

FWIW; Vim colors #if 0 blocks as if they were comments.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

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

<20240321133230.122@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34615&group=comp.lang.c#34615

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 433-929-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: Block Comments Or Rest-Of-Line Comments?
Date: Thu, 21 Mar 2024 20:35:33 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 44
Message-ID: <20240321133230.122@kylheku.com>
References: <utgjh0$21nsq$2@dont-email.me> <uthj7e$29aoc$2@dont-email.me>
<uthne5$2ad1b$1@dont-email.me> <87msqr1j8x.fsf@nosuchdomain.example.com>
<5D0LN.84949$_a1e.79924@fx16.iad>
Injection-Date: Thu, 21 Mar 2024 20:35:33 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="8a88f4f3d1bb162453330ac9f4d394b5";
logging-data="2546182"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+OxQnd5poVDq9Tm0KNbSKVsHL5w+mXT1A="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:3Pa7CbcDKhFxPtHELqLPRXBdC24=
 by: Kaz Kylheku - Thu, 21 Mar 2024 20:35 UTC

On 2024-03-21, Scott Lurndal <scott@slp53.sl.home> wrote:
> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>>Richard Harnden <richard.nospam@gmail.invalid> writes:
>>[...]
>>> And sometimes, when it's not a really a comment, but rather a block of
>>> code I don't want right now:
>>>
>>> #ifdef 0
>>> ...
>>> #endif
>>
>>I think you mean "#if 0".
>>
>>I use that sometimes, but one disadvantage is that if you're viewing the
>>middle of a very large block of code, it can be hard to tell that it's
>>been "commented" out.
>
> Often syntax highlighting (e.g. vim) will solve that.
>
> In projects with many fingers in the pie, I generally prefer either a
> descriptive (and undefined) macro name or a block comment in
> the #if 0 region to indicate exactly _why_ it was not just removed
> from the source file entirely.
>
> Makes it easier for whomever is reading and/or maintaining the
> code to follow it.

I have a simpler approach: commits which introduced commented-out
code, whether with #if 0, or any other means, shall not be merged.

I don't perpetrate that in my open source projects, and "-1" such
submissions at work.

When someone wants to remove code, I encourage them to actually
delete it. The comment about why it was deleted goes into the
commit log.

Usually people are relieved; deleting it was what they wanted, but they
weren't sure due the code not being their area or whatever.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

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

<uti7uu$2ed01$3@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34617&group=comp.lang.c#34617

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo...@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.lang.c
Subject: Re: Block Comments Or Rest-Of-Line Comments?
Date: Thu, 21 Mar 2024 21:14:06 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <uti7uu$2ed01$3@dont-email.me>
References: <utgjh0$21nsq$2@dont-email.me> <uthva5$2k4da$1@i2pn2.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 21 Mar 2024 21:14:06 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="badb6633f042ee08dd03f65d8f49603e";
logging-data="2569217"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18BHD8j0sXCrhoEsLBh1Ltt"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:6nZzoOlNS84TlDPc4TUealjLWa0=
 by: Lawrence D'Oliv - Thu, 21 Mar 2024 21:14 UTC

On Thu, 21 Mar 2024 19:46:29 +0100, fir wrote:

> ... mostly i use // coments becouse i nearly
> exclusively use comments to comment out code and in editor i got it
> under control+shift+c

1) You can comment out entire blocks at once with block comments
2) This is why we have version control; just delete the unneeded block,
since you can get it back from your commit history if you change your mind
later anyway.

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

<uti83u$2ed01$4@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34618&group=comp.lang.c#34618

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo...@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.lang.c
Subject: Re: Block Comments Or Rest-Of-Line Comments?
Date: Thu, 21 Mar 2024 21:16:46 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <uti83u$2ed01$4@dont-email.me>
References: <utgjh0$21nsq$2@dont-email.me> <uth66l$266da$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 21 Mar 2024 21:16:46 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="badb6633f042ee08dd03f65d8f49603e";
logging-data="2569217"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+oV8ND3vSjOoNd6ngmMEE6"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:xKPWB43nIwMa5u2+ZkIbYmAsg44=
 by: Lawrence D'Oliv - Thu, 21 Mar 2024 21:16 UTC

On Thu, 21 Mar 2024 13:37:57 +0200, Mikko wrote:

> On 2024-03-21 06:19:13 +0000, Lawrence D'Oliveiro said:
>
>> 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.

But putting them in front of the values looks more like the syntax in
languages (like Ada and Python) that do allow specification of argument
keywords.

And maybe, in future, if it becomes valid in C (or some successor), then
updating the code should be as simple as removing the comment symbols.

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

<uti86q$2ed01$5@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34619&group=comp.lang.c#34619

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo...@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.lang.c
Subject: Re: Block Comments Or Rest-Of-Line Comments?
Date: Thu, 21 Mar 2024 21:18:19 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 7
Message-ID: <uti86q$2ed01$5@dont-email.me>
References: <utgjh0$21nsq$2@dont-email.me> <uthj7e$29aoc$2@dont-email.me>
<uthne5$2ad1b$1@dont-email.me> <87msqr1j8x.fsf@nosuchdomain.example.com>
<uti2gj$2d5i5$1@dont-email.me> <87edc31i3e.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 21 Mar 2024 21:18:19 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="badb6633f042ee08dd03f65d8f49603e";
logging-data="2569217"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Vu1PcJV1oI1p+4MhM7QLt"
User-Agent: Pan/0.155 (Kherson; fc5a80b8)
Cancel-Lock: sha1:zm86l0s4maedfvWNdyd9Go7H0Lg=
 by: Lawrence D'Oliv - Thu, 21 Mar 2024 21:18 UTC

On Thu, 21 Mar 2024 12:48:53 -0700, Keith Thompson wrote:

> It's a Perl script ...

Shame. I was hoping for something in, say, Emacs Lisp, that can be invoked
from directly within the editor, operating on a selected region within the
buffer, and bound to a keystroke.

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

<875xxf1a3q.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34621&group=comp.lang.c#34621

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: Block Comments Or Rest-Of-Line Comments?
Date: Thu, 21 Mar 2024 15:41:29 -0700
Organization: None to speak of
Lines: 29
Message-ID: <875xxf1a3q.fsf@nosuchdomain.example.com>
References: <utgjh0$21nsq$2@dont-email.me> <uthj7e$29aoc$2@dont-email.me>
<uthne5$2ad1b$1@dont-email.me>
<87msqr1j8x.fsf@nosuchdomain.example.com>
<20240321132129.448@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="0bf58c5e3e50115de10475b5e7b86fc1";
logging-data="2609135"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18demqpyiPmxvEExEIxv+A9"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:QjJn62qi/MZOD2z1ev/AABeNp5Y=
sha1:E4zUK8iySE8Dqbjh1+mRXdEl21Q=
 by: Keith Thompson - Thu, 21 Mar 2024 22:41 UTC

Kaz Kylheku <433-929-6894@kylheku.com> writes:
> On 2024-03-21, Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>> Richard Harnden <richard.nospam@gmail.invalid> writes:
>> [...]
>>> And sometimes, when it's not a really a comment, but rather a block of
>>> code I don't want right now:
>>>
>>> #ifdef 0
>>> ...
>>> #endif
>>
>> I think you mean "#if 0".
>>
>> I use that sometimes, but one disadvantage is that if you're viewing the
>> middle of a very large block of code, it can be hard to tell that it's
>> been "commented" out.
>
> FWIW; Vim colors #if 0 blocks as if they were comments.

Sure, but I don't always view code in a way that allows for
language-specific highlighting. (In fact I rarely do so, and I'm not
willing to assume that everyone else always does so.)

I developed my habits when syntax highlighting wasn't an option.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Medtronic
void Void(void) { Void(); } /* The recursive call of the void */

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

<871q8319o9.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34622&group=comp.lang.c#34622

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: Block Comments Or Rest-Of-Line Comments?
Date: Thu, 21 Mar 2024 15:50:46 -0700
Organization: None to speak of
Lines: 29
Message-ID: <871q8319o9.fsf@nosuchdomain.example.com>
References: <utgjh0$21nsq$2@dont-email.me> <uthj7e$29aoc$2@dont-email.me>
<uthne5$2ad1b$1@dont-email.me>
<87msqr1j8x.fsf@nosuchdomain.example.com>
<uti2gj$2d5i5$1@dont-email.me>
<87edc31i3e.fsf@nosuchdomain.example.com>
<uti86q$2ed01$5@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="0bf58c5e3e50115de10475b5e7b86fc1";
logging-data="2609135"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18jl7jUTe+RfbhKlNoWrKGt"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:hC97idtQRWzKOX7/0aO+KlzfWqw=
sha1:HUmlLKEHC/bgx5BgfwzgSoM418M=
 by: Keith Thompson - Thu, 21 Mar 2024 22:50 UTC

Lawrence D'Oliveiro <ldo@nz.invalid> writes:
> On Thu, 21 Mar 2024 12:48:53 -0700, Keith Thompson wrote:
>> It's a Perl script ...
>
> Shame. I was hoping for something in, say, Emacs Lisp, that can be invoked
> from directly within the editor, operating on a selected region within the
> buffer, and bound to a keystroke.

Feel free to write it. (And an Emacs Lisp function doesn't help me in vim.)

Perhaps I should have mentioned that the Perl script I posted reads from
stdin and writes to stdout. It can also read from one or more files
named on its command line.

It slurps all its input into memory. I could have written it to stream
stdin to stdout, which could work better for large inputs, but the
current version works well enough for me.

#if 0
* Meanwhile, Emacs can invoke an external command on a region of text, and
* you can bind that to a keystroke if you like. I used it on this paragraph.
#endif /* 0 */

"shell-command-on-region" is bound to "M-|" (Alt-| or Esc |).

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Medtronic
void Void(void) { Void(); } /* The recursive call of the void */

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

<utjhfn$2r0cr$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34625&group=comp.lang.c#34625

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: Block Comments Or Rest-Of-Line Comments?
Date: Fri, 22 Mar 2024 10:02:47 +0100
Organization: A noiseless patient Spider
Lines: 65
Message-ID: <utjhfn$2r0cr$1@dont-email.me>
References: <utgjh0$21nsq$2@dont-email.me> <uth66l$266da$1@dont-email.me>
<uti83u$2ed01$4@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 22 Mar 2024 09:02:47 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="07a44ddb34b47981e78dc5e82c11a0d6";
logging-data="2982299"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/zjoIM0nNP+n/OnP56AzepmBIk/Fg6dbU="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:lP11qlXedLwrEXWlJHZqbY9CV9g=
In-Reply-To: <uti83u$2ed01$4@dont-email.me>
Content-Language: en-GB
 by: David Brown - Fri, 22 Mar 2024 09:02 UTC

On 21/03/2024 22:16, Lawrence D'Oliveiro wrote:
> On Thu, 21 Mar 2024 13:37:57 +0200, Mikko wrote:
>
>> On 2024-03-21 06:19:13 +0000, Lawrence D'Oliveiro said:
>>
>>> 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.
>
> But putting them in front of the values looks more like the syntax in
> languages (like Ada and Python) that do allow specification of argument
> keywords.
>

Why would you want your C code to look like Python? That's as silly as
wanting your Python code to look like C code. The languages are
significantly different - each with their strengths and weaknesses, and
each suitable for quite different kinds of programming tasks.

I can appreciate wanting to document what the parameters are in a
function that takes far too many parameters. I don't see any benefit in
doing so in a way that looks vaguely like an entirely different
programming language.

gdImageCopyResampled
( ResizedFrame, // destination frame
Context.StillFrame, // source frame
0, 0, // destination x, y
0, 0, // source x, y
ResizedFrame->sx, // frame sizes
ResizedFrame->sy,
Context.StillFrame->sx,
Context.StillFrame->sy
);

That is simpler and more informative than your style (IMHO of course).

> And maybe, in future, if it becomes valid in C (or some successor), then
> updating the code should be as simple as removing the comment symbols.

I am a fan of being able to name parameters in languages that allow it.
I am quite confident that this will never come to C. It /might/ make it
into C++, but as people have been writing proposals to do so for 20
years at least, I am not holding my breath.

In the meantime, you can use structs with parameters and use designated
initialisers and compound literals to get a similar effect but with a
heavier and less flexible syntax. Or you can use specific types for
each parameter, along with macros (or constructors in C++), to ensure
that you can't get the parameters mixed up. Again, it's more boiler
plate and a heavier syntax than named parameters would be.

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

<utjht2$2r0cr$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34626&group=comp.lang.c#34626

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: Block Comments Or Rest-Of-Line Comments?
Date: Fri, 22 Mar 2024 10:09:54 +0100
Organization: A noiseless patient Spider
Lines: 76
Message-ID: <utjht2$2r0cr$2@dont-email.me>
References: <utgjh0$21nsq$2@dont-email.me> <uthj7e$29aoc$2@dont-email.me>
<uthne5$2ad1b$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 22 Mar 2024 09:09:54 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="07a44ddb34b47981e78dc5e82c11a0d6";
logging-data="2982299"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19C7YRmau4HITfUaICNX1bge3oRI1sHRB0="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:LM/oRttBNPjwJrkhfgiL1WRiniw=
Content-Language: en-GB
In-Reply-To: <uthne5$2ad1b$1@dont-email.me>
 by: David Brown - Fri, 22 Mar 2024 09:09 UTC

On 21/03/2024 17:32, Richard Harnden wrote:
> On 21/03/2024 15:20, David Brown wrote:
>> On 21/03/2024 07: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?
>>> //
>>>
>>
>> I 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.
>
> And sometimes, when it's not a really a comment, but rather a block of
> code I don't want right now:
>
> #ifdef 0

"#if 0", presumably.

> ...
> #endif
>

Yes, I do that too. But if it is more than just a fairly trivial amount
of code, and not just for quite tests during development, then I hugely
prefer to give the block a name:

// Explanation of EnableExtraChecks ...
#define EnableExtraChecks 1

....

#if EnableExtraChecks
....
#endif // #if EnableExtraChecks

Depending on the circumstances, the guard macro definition might be at
the start of the file, or it might be just before the commented-out
block. But even in the later case, giving it a name like this makes it
easier to match up when the #endif (and perhaps #else) has a comment.
It also makes it easier to get right if there are several blocks that
get commented out, whether they use the same or different guards.

Note that some coding standards (such as MISRA) do not allow this
technique, because it can be hard (without a good highlighting editor or
IDE) to see if code is active or disabled.

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

<86edc2l7lw.fsf@linuxsc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=34631&group=comp.lang.c#34631

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: Block Comments Or Rest-Of-Line Comments?
Date: Fri, 22 Mar 2024 06:27:23 -0700
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <86edc2l7lw.fsf@linuxsc.com>
References: <utgjh0$21nsq$2@dont-email.me> <_iXKN.556576$PuZ9.147822@fx11.iad> <86r0g3liii.fsf@linuxsc.com> <uthsgp$94j$1@reader1.panix.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: dont-email.me; posting-host="43a124101bc8549bfa1c6f6d248b1944";
logging-data="3091143"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19rfNVDvsAOCkkvaa1LoRFa97u5Q/KjjFk="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:SDqfrjD6pMAq9kD4Z+vBWjug9QA=
sha1:N0FrOy9THPxxJJf65JEpQNySBgg=
 by: Tim Rentsch - Fri, 22 Mar 2024 13:27 UTC

cross@spitfire.i.gajendra.net (Dan Cross) writes:

> In article <86r0g3liii.fsf@linuxsc.com>,
> Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:
>
>> scott@slp53.sl.home (Scott Lurndal) writes:
>>
>>> Lawrence D'Oliveiro <ldo@nz.invalid> writes:
>>>
>>>> The original comment delimiters in C were copied from PL/I: everything
>>>
>>> Cite?
>>
>> Seen in the B language manual:
>>
>> Comments are delimited as in PL/I by /* and */.
>>
>> https://www.bell-labs.com/usr/dmr/www/kbman.html
>>
>> Note that this style of commenting was not present in
>> B's precursor language, BCPL.
>
> It would be appropriate to qualify this statement with some kind
> of timeframe as BCPL is still used (albeit not widely, I assume).

The PL/I style of commenting was not present in BCPL at the time B
was being defined. My source is MIT Project Mac Memorandum-M-352
dated July 21, 1967. I expect this document can be found on the
net but I don't have a link for it.

Pages:123
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor