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.
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 ofI think you mean "#if 0".
code I don't want right now:
#ifdef 0
...
#endif
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?
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:I think you mean "#if 0".
#ifdef 0
...
#endif
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";
```
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.
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.
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.
... mostly i use // coments becouse i nearly
exclusively use comments to comment out code and in editor i got it
under control+shift+c
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.
It's a Perl script ...
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.
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.
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.
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
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).
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.
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".
On 3/21/24 15: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".
I'm sure he did. However, I'd like to mention that I have occasionally
used #ifdef with a macro name that I haven't #defined, and have no plans
to #define, but which describes the reason why I'm commenting this
section out. This is purely to document my reason, but should I ever
change my mind, I can simply #define the corresponding macro.
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?
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.
... I have occasionally
used #ifdef with a macro name that I haven't #defined, and have no plans
to #define, but which describes the reason why I'm commenting this
section out.
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.
And maybe, in future, if it becomes valid in C (or some successor),Why would you want your C code to look like Python?
then updating the code should be as simple as removing the comment
symbols.
On Fri, 22 Mar 2024 10:02:47 +0100, David Brown wrote:[...]
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:
Why would you want your C code to look like Python?
Is “Python” some kind of trigger word with you? Soon as you see that, a switch clicks off in your brain, and you are incapable of focussing on anything else that was said?
On 3/22/2024 7:58 PM, Lawrence D'Oliveiro wrote:
On Fri, 22 Mar 2024 10:02:47 +0100, David Brown wrote:
On 21/03/2024 22:16, Lawrence D'Oliveiro wrote:
On Thu, 21 Mar 2024 13:37:57 +0200, Mikko wrote:Why would you want your C code to look like Python?
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
);
Is “Python” some kind of trigger word with you? Soon as you see that, a >> switch clicks off in your brain, and you are incapable of focussing on
anything else that was said?
Notice the name of the group?
On Fri, 22 Mar 2024 10:02:47 +0100, David Brown wrote:
On 21/03/2024 22:16, Lawrence D'Oliveiro wrote:
On Thu, 21 Mar 2024 13:37:57 +0200, Mikko wrote:Why would you want your C code to look like Python?
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.
Is “Python” some kind of trigger word with you? Soon as you see that, a switch clicks off in your brain, and you are incapable of focussing on anything else that was said?
On 23/03/2024 03:58, Lawrence D'Oliveiro wrote:
On Fri, 22 Mar 2024 10:02:47 +0100, David Brown wrote:
On 21/03/2024 22:16, Lawrence D'Oliveiro wrote:
On Thu, 21 Mar 2024 13:37:57 +0200, Mikko wrote:Why would you want your C code to look like Python?
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.
Is “Python” some kind of trigger word with you? Soon as you see that, a >> switch clicks off in your brain, and you are incapable of focussing on
anything else that was said?
No, I am quite happy with Python, and use it regularly. It is simply
that Python and C are very different languages, and I see no benefit in trying to make one look like the other. (And I talked more about Python than Ada because my knowledge of Ada is a lot more limited compared to
my knowledge and experience with Python - and I expect that pattern is common amongst other people in c.l.c.)
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?
A normal person won't compulsively comment very function argument,
Kaz Kylheku <643-408-1753@kylheku.com> writes:
A normal person won't compulsively comment very function argument,
Well, they might if they're generating documentation from the
comments.
Lowell Gilbert <lgusenet@be-well.ilk.org> writes:
Kaz Kylheku <643-408-1753@kylheku.com> writes:
A normal person won't compulsively comment very function argument,
Well, they might if they're generating documentation from the
comments.
The discussion was about function arguments in a call. Documentation
would, presumably, be generated from comments on (formal) parameters in
a function declaration.
Kaz Kylheku <643-408-1753@kylheku.com> writes:
A normal person won't compulsively comment very function argument,
Well, they might if they're generating documentation from the comments.
Even then, it would usually only be a concern for API-type functions,
which means a fairly small share of a typical codebase.
On 3/21/2024 2:19 AM, Lawrence D'Oliveiro wrote:
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?
//
Get yourself some Notepad++.
Highlight a block of comments and hit Ctrl + Q.
Get yourself some Notepad++.
On 24.04.24 14:36, Blue-Maned_Hawk wrote:
DFS wrote:BULSHIT.
Get yourself some Notepad++.
Not everybody can afford a machine powerful enough for a fancy text
editor like that.
I run notepad++ on a 20 year old xp pro machine, and never had a
problem.
DFS wrote:
Get yourself some Notepad++.
Not everybody can afford a machine powerful enough for a fancy text editor like that.
Sysop: | Tetrazocine |
---|---|
Location: | Melbourne, VIC, Australia |
Users: | 7 |
Nodes: | 8 (0 / 8) |
Uptime: | 125:35:37 |
Calls: | 46 |
Files: | 21,492 |
Messages: | 64,827 |