Thread View: comp.lang.c++
158 messages
158 total messages
Page 4 of 4
Started by Lynn McGuire
Thu, 05 Nov 2026 23:42
Page 4 of 4 • 158 total messages
Re: [meta] O tempora, o mores! (was Re: does an expression in a logical statement need parenthesis for proper evaluation?)
Author: Tristan Wibberley
Date: Mon, 23 Nov 2026 07:33
Date: Mon, 23 Nov 2026 07:33
20 lines
2451 bytes
2451 bytes
On 22/11/2026 23:48, Ross Finlayson wrote: > Also, "Dunning-Kruger" should be invoked very sparingly. Hands up who thinks they understand the Dunning-Kruger effect? -- Tristan Wibberley The message body is Copyright (C) 2026 Tristan Wibberley except citations and quotations noted. All Rights Reserved except that you may, of course, cite it academically giving credit to me, distribute it verbatim as part of a usenet system or its archives, and use it to promote my greatness and general superiority without misrepresentation of my opinions other than my opinion of my greatness and general superiority which you _may_ misrepresent. You definitely MAY NOT train any production AI system with it but you may train experimental AI that will only be used for evaluation of the AI methods it implements.
Yet another digression (was Re: [meta] O tempora, o mores! (was Re: does an expression in a logical statement need parenthesis f...
Author: Janis Papanagnou
Date: Mon, 23 Nov 2026 10:06
Date: Mon, 23 Nov 2026 10:06
43 lines
3969 bytes
3969 bytes
On 2026-11-22 18:04, Ross Finlayson wrote:
>
> [...] Then,
> for example there's "blank line at the end of a file or no blank line",
(Note that your wording is expressing a shifted perspective.)
> for example Java-style has "no trailing line", here it's that
> the files always have a trailing empty line, then that for
> accounts like "cat all the files" that they're not ellided.
I've never heard about "blank line at the end of a file". I
suppose what you mean here is the effect that may be described:
(a) every line should be terminated by a newline character,
(b) some editors seem to display that proper line termination
(for the last data line) as an empty line on their GUI.
Note that this is an issue some editors introduce by their way
of _representing_ a text, and not a property of the text data.
A _file_ containing data (with line terminators '\n')
line one\n
line two\n
...
last line\n
has no "empty last line" (whatever your editor displays).
The consequence of editors displaying a spurious empty line
when all lines (including the last) are consistently terminated
with a newline character is obviously that folks using such
editors and have a tendency to consider a [spurious appearing]
"empty line" as unnecessary ballast (and omit line termination)
may run into problems like the 'cat' case you hinted on.
Folks are free to use more sophisticated editors, or configure
the ("misbehaving") editors to behave properly (if they allow
that), or just live with the consequences (and disseminate that
data problem further into the development team).
Janis
>
> [...]
Re: Yet another digression (was Re: [meta] O tempora, o mores! (was Re: does an expression in a logical statement need parenthes...
Author: James Kuyper
Date: Tue, 24 Nov 2026 04:15
Date: Tue, 24 Nov 2026 04:15
28 lines
3375 bytes
3375 bytes
On 2026-11-23 05:06, Janis Papanagnou wrote: > On 2026-11-22 18:04, Ross Finlayson wrote: >> >> [...] Then, >> for example there's "blank line at the end of a file or no blank line", > > (Note that your wording is expressing a shifted perspective.) > >> for example Java-style has "no trailing line", here it's that >> the files always have a trailing empty line, then that for >> accounts like "cat all the files" that they're not ellided. > > I've never heard about "blank line at the end of a file". I no longer see Ross's messages directly, only what's quoted in other people's responses. Could he be referring to what the C standard says about text streams: "Whether the last line requires a terminating new-line character is implementation-defined." (7.24.2p2 n3998.pdf) I wouldn't describe that as "blank line or no blank line", but I could imagine it being misunderstood that way. The C++ standard defines the behavior of many fundamental <iostream> functions in terms of the C standard library's routines, so I suspect that this also applies to C++.
Re: Yet another digression (was Re: [meta] O tempora, o mores! (was Re: does an expression in a logical statement need parenthes...
Author: Janis Papanagnou
Date: Tue, 24 Nov 2026 06:40
Date: Tue, 24 Nov 2026 06:40
60 lines
4722 bytes
4722 bytes
On 2026-11-24 05:15, James Kuyper wrote: > On 2026-11-23 05:06, Janis Papanagnou wrote: >> On 2026-11-22 18:04, Ross Finlayson wrote: >>> >>> [...] Then, >>> for example there's "blank line at the end of a file or no blank line", >> >> (Note that your wording is expressing a shifted perspective.) >> >>> for example Java-style has "no trailing line", here it's that >>> the files always have a trailing empty line, then that for >>> accounts like "cat all the files" that they're not ellided. >> >> I've never heard about "blank line at the end of a file". > > I no longer see Ross's messages directly, only what's quoted in other > people's responses. > > Could he be referring to what the C standard says about text streams: As what he writes appears often a bit convoluted it's not clear to me whether he was implicitly referring to the C-standard. There was no explicit reference to the C-standard (as far as I recall). Given the wording and context as presented (Tabs vs. Spaces, long lines, and meta-rambling etc.) it appeared more to be a statement about editors; data representation, files, the editors' GUIs. All somehow mixed in one (arguable; at least imprecise) statement. If we know (and spell out) these differences readers may get aware of the potential problems and act accordingly (which was my point). > > "Whether the last line requires a terminating new-line character is > implementation-defined." (7.24.2p2 n3998.pdf) Working in POSIX environments, though, we have the certainty and we need not rely on the (yet another) uncertainty that the C-standard exposes here. (Personally I'm not much concerned as I'm always creating terminated lines in text-files. I'm also using an editor where the editor cares about detecting and creating correct representations in files, and which facilitates me to control that in (very rare) cases where I'd need it.) > > I wouldn't describe that as "blank line or no blank line", but I could > imagine it being misunderstood that way. Given the representations of his thoughts it's easy to misunderstand his intention. Any answers will have to consider the thereby induced uncertainty. > > The C++ standard defines the behavior of many fundamental <iostream> > functions in terms of the C standard library's routines, so I suspect > that this also applies to C++. Janis
Re: Yet another digression (was Re: [meta] O tempora, o mores! (was Re: does an expression in a logical statement need parenthes...
Author: Ross Finlayson
Date: Tue, 24 Nov 2026 16:37
Date: Tue, 24 Nov 2026 16:37
62 lines
5075 bytes
5075 bytes
On 11/23/2026 08:15 PM, James Kuyper wrote: > On 2026-11-23 05:06, Janis Papanagnou wrote: >> On 2026-11-22 18:04, Ross Finlayson wrote: >>> >>> [...] Then, >>> for example there's "blank line at the end of a file or no blank line", >> >> (Note that your wording is expressing a shifted perspective.) >> >>> for example Java-style has "no trailing line", here it's that >>> the files always have a trailing empty line, then that for >>> accounts like "cat all the files" that they're not ellided. >> >> I've never heard about "blank line at the end of a file". > > I no longer see Ross's messages directly, only what's quoted in other > people's responses. > > Could he be referring to what the C standard says about text streams: > > "Whether the last line requires a terminating new-line character is > implementation-defined." (7.24.2p2 n3998.pdf) > > I wouldn't describe that as "blank line or no blank line", but I could > imagine it being misunderstood that way. > > The C++ standard defines the behavior of many fundamental <iostream> > functions in terms of the C standard library's routines, so I suspect > that this also applies to C++. > I know what I meant, it doesn't take a generous reading to see that's what's _relevant_ as an example. The generous vis-a-vis the in-generous reading has that usual accounts like for "Grice" again or "effective communication", here has that having a "blank line" at the end of a compilation unit's sources, is usually considered a reasonable thing, vis-a-vis, for example, using line-oriented data and where either line-endings or end-of-file are record-separators, and _not_ having blank lines, i.e., there are settings where the last character in the file being a newline (i.e., resulting a "blank line", in the generous reading, for a line-reader that interprets either line-endings or end-of-file as record-separators and, well, end-of-file), is allowed, and settings where it ain't, that then in source files, about which various opinionated pretty-printers eventually have an option someone will tweak (and, generally it's a rule that "tweakers are un-reliable"), finding a chance to save one character-set character-set-encoding language's/system's newline or line-ending, like people who can't stand semi-colons as statement-endings, then has that people who omit the Oxford, standard, Harvard, serial comma: are considered slights to the language. I'm not dis-interested your opinion, haven't much heard of it. Perhaps you have subtler influences than I'd otherwise infer.
Re: Yet another digression (was Re: [meta] O tempora, o mores! (was Re: does an expression in a logical statement need parenthes...
Author: Keith Thompson
Date: Wed, 25 Nov 2026 00:50
Date: Wed, 25 Nov 2026 00:50
49 lines
4117 bytes
4117 bytes
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
> On 2026-11-24 05:15, James Kuyper wrote:
[...]
>> "Whether the last line requires a terminating new-line character is
>> implementation-defined." (7.24.2p2 n3998.pdf)
>
> Working in POSIX environments, though, we have the certainty and we
> need not rely on the (yet another) uncertainty that the C-standard
> exposes here.
>
> (Personally I'm not much concerned as I'm always creating terminated
> lines in text-files. I'm also using an editor where the editor cares
> about detecting and creating correct representations in files, and
> which facilitates me to control that in (very rare) cases where I'd
> need it.)
[...]
Here's what POSIX says.
https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/V1_chap03.html
3.185 Line
A sequence of zero or more non-<newline> characters plus a
terminating <newline> character.
3.387 Text File
A file that contains characters organized into zero or more
lines. The lines do not contain NUL characters and none can
exceed {LINE_MAX} bytes in length, including the <newline>
character. Although POSIX.1-2024 does not distinguish between
text files and binary files (see the ISO C standard), many
utilities only produce predictable or meaningful output when
operating on text files. The standard utilities that have such
restrictions always specify "text files" in their STDIN or
INPUT FILES sections.
So as far as C is concerned, a non-empty file not ending in a newline
may or may not be a text file, but in POSIX it is not. And yes,
many tools will, at least by default, ensure that a created or
updated non-empty text file will end with a newline character.
But there are text-like files that don't end in a newline character
(or that have lines exceeding LINE_MAX bytes), and I expect the
tools I use to deal with such files reasonably, even if POSIX
does't require it.
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */
Re: Yet another digression (was Re: [meta] O tempora, o mores! (was Re: does an expression in a logical statement need parenthes...
Author: Janis Papanagnou
Date: Wed, 25 Nov 2026 08:59
Date: Wed, 25 Nov 2026 08:59
53 lines
4240 bytes
4240 bytes
On 2026-11-25 01:50, Keith Thompson wrote: > Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes: >> On 2026-11-24 05:15, James Kuyper wrote: > [...] >>> "Whether the last line requires a terminating new-line character is >>> implementation-defined." (7.24.2p2 n3998.pdf) >> >> Working in POSIX environments, though, we have the certainty and we >> need not rely on the (yet another) uncertainty that the C-standard >> exposes here. >> >> (Personally I'm not much concerned as I'm always creating terminated >> lines in text-files. I'm also using an editor where the editor cares >> about detecting and creating correct representations in files, and >> which facilitates me to control that in (very rare) cases where I'd >> need it.) > [...] > > Here's what POSIX says. > [snip] Yes, that's what I was referring to. > > So as far as C is concerned, a non-empty file not ending in a newline > may or may not be a text file, but in POSIX it is not. And yes, > many tools will, at least by default, ensure that a created or > updated non-empty text file will end with a newline character. > > But there are text-like files that don't end in a newline character (There are text files that don't have CRs, NLs, or CR-NL at all! Have a look at fixed record files on mainframes. And then there's also occasionally been "end-of-file characters" on some systems.) You may introduce, beside [POSIX] text-file and [non-text] binary file, a third category "text-like" files, but that doesn't add anything but confusion about what those files characterize beyond the two categories given and is at best suitable to "explain" any deviation from the terms that abstain from "like" descriptions. > (or that have lines exceeding LINE_MAX bytes), and I expect the > tools I use to deal with such files reasonably, even if POSIX > does't require it. If you're operating only with tools in an own ecosystem you will likely not observe any problems. Problems arise if your data has to be processed with different tools (and also across different platforms). HTH. Janis
Page 4 of 4 • 158 total messages
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads