Richard Heathfield <> writes:
> Walter Banks wrote:
[...]
> > Only the last backslash on
>> any physical source line shall be eligible for being part
>> of such a splice.
>
> This is redundant.
That was my thought as well, but I presume the authors had something in
mind when they wrote that sentence.
The only case I can think of where it makes a difference is an
implementation where physical source lines are terminated by something
other than a new-line character but can contain embedded new-line
characters. Assuming that physical source lines are terminated by '@',
you could have a physical source line like this, where \n represents
a new-line character:
x = 42; \\n /* a comment */ \@
After translation phase 1, we have:
x = 42; \\n /* a comment */ \\n
which makes two logical source lines. The first backslash is
immediately followed by a new-line, so it would normally be spliced,
but it's not the last backslash on the physical source line, so
it's a syntax error.
That might make some sense as a way to flag a certain kind of very
obscure error, but if the second backslash is removed then the first one
*is* the last backslash on the physical source line so it will be
spliced.
So what is the real purpose of the "Only the last backslash" rule?
> <snip>
>
>> Byte Craft's compilers strip trailing white space.
>
> I think that renders those compilers non-conforming in that regard. In
> this case, that may well be a price you're prepared to pay. Is there at
> least some way of turning the stripping off?
Trailing whitespace cannot be stripped in translation phase 2, but I
believe it can be stripped in translation phase 1.
For example, think about a system where lines in text files are
fixed-length with trailing spaces. On such a system, it would be
unpleasant to require line-splicing backslashes to appear in the
last column of the physical line.
Can anyone think of a case where stripping all trailing whitespace
in phase 1 would either break or change the meaning of a valid
translation unit? I can't. The only drawback is that it means
a file that would be rejected by other compilers could compile
without any diagnostics.
If the standard were modified to require all trailing whitespace
to be removed in translation phase 1, would that break anything?
--
Keith Thompson (The_Other_Keith)
kst- <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"