On Tue, 20 Oct 2026 15:06:48 -0500, Lynn McGuire wrote:
The key to writing any software is lots of commenting.
A key point about comments is they should explain *why* the code is
On Tue, 20 Oct 2026 20:20:39 -0000 (UTC), Lawrence D˜Oliveiro wrote:
On Tue, 20 Oct 2026 15:06:48 -0500, Lynn McGuire wrote:
The key to writing any software is lots of commenting.
A key point about comments is they should explain *why* the code is
the win for comment it is when code explain itself with 0 comment
Op 02.nov.2026 om 10:54 schreef Rosario19:
On Tue, 20 Oct 2026 20:20:39 -0000 (UTC), Lawrence D˜Oliveiro wrote:
On Tue, 20 Oct 2026 15:06:48 -0500, Lynn McGuire wrote:
The key to writing any software is lots of commenting.
A key point about comments is they should explain *why* the code is
the win for comment it is when code explain itself with 0 comment
Code can only explain what it does, what the algorithm is.
Code cannot explain why that algorithm was chosen. That is where
comments are for.
Unfortuately, a lot of people (especially CS weenies) love to loudly proclaim, "My code is so readable that no comments are necessary!"
On 2026-10-20, Lawrence D?Oliveiro <ldo@nz.invalid> wrote:
On Tue, 20 Oct 2026 19:04:55 GMT, Charlie Gibbs wrote:
The undisciplined use of GOTOs is bad, agreed.
Is there such a thing as a *disciplined* use of gotos?
Yes, especially in COBOL or assembly language. For instance,
a GOTO to the end of a function ensures any of its cleanup code
gets executed, and fulfils a goal of structured proramming:
each function has one exit point.
I find the C code I write tends to do a lot of dynamic resource
allocations. These can sometimes fail with errors. So error recovery
will invariably involve cleaning up those parts of the allocations
which already succeeded.
Gotos are no good for this; you need to exit
levels of structure nesting one by one, disposing of allocations as
you go.
On Tue, 20 Oct 2026 23:18:44 GMT, Charlie Gibbs wrote:
On 2026-10-20, Lawrence D?Oliveiro <ldo@nz.invalid> wrote:
On Tue, 20 Oct 2026 19:04:55 GMT, Charlie Gibbs wrote:
The undisciplined use of GOTOs is bad, agreed.
Is there such a thing as a *disciplined* use of gotos?
Yes, especially in COBOL or assembly language. For instance,
a GOTO to the end of a function ensures any of its cleanup code
gets executed, and fulfils a goal of structured proramming:
each function has one exit point.
I find the C code I write tends to do a lot of dynamic resource
allocations. These can sometimes fail with errors. So error recovery
will invariably involve cleaning up those parts of the allocations
which already succeeded.
Gotos are no good for this; you need to exit
levels of structure nesting one by one, disposing of allocations as
you go.
If in the start of the function all pointer are NULL, and in the end
of the function there are all the free()
I not have find all your problems with possibly multiple goto that
point to the end of the function
On 2026-11-02, Fred. Zwarts <F.Zwarts@HetNet.nl> wrote:
Op 02.nov.2026 om 10:54 schreef Rosario19:
On Tue, 20 Oct 2026 20:20:39 -0000 (UTC), Lawrence D˜Oliveiro wrote:
On Tue, 20 Oct 2026 15:06:48 -0500, Lynn McGuire wrote:
The key to writing any software is lots of commenting.
A key point about comments is they should explain *why* the code is
the win for comment it is when code explain itself with 0 comment
Code can only explain what it does, what the algorithm is.
Code cannot explain why that algorithm was chosen. That is where
comments are for.
Unfortuately, a lot of people (especially CS weenies) love to
loudly proclaim, "My code is so readable that no comments are
necessary!" (Sometimes they apply this argument to their choice
of programming language as well.) They're usually wrong.
| Sysop: | Tetrazocine |
|---|---|
| Location: | Melbourne, VIC, Australia |
| Users: | 3 |
| Nodes: | 8 (0 / 8) |
| Uptime: | 51:07:18 |
| Calls: | 223 |
| Files: | 21,513 |
| Messages: | 83,425 |